npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-firebase-extended-notification

v2.2.0

Published

Simple notification message from server as "data" that allows more options as how it will apear to the notified user.

Downloads

49

Readme

cordova-plugin-firebase-extended-notification

npm npm GitHub license GitHub issues GitHub forks GitHub stars Known Vulnerabilities DeepScan grade

Simple notification message from server as "data" that allows more options as how it will apear to the notified user.

For a practical example, look into https://github.com/andrehtissot/cordova-plugin-firebase-extended-notification-app-example. Check the wiki before creating an issue.

The default notification from your server to android devices is limited to the options "body", "title" and "icon", like the exemple below:

{
  "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
  "notification" : {
    "body" : "great match!",
    "title" : "Portugal vs. Denmark",
    "icon" : "myicon"
  }
}

References: https://firebase.google.com/docs/cloud-messaging/concept-options#notifications_and_data_messages

This plugin allows a nicer notification without cordova configurations, like the example below:

{
  "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
  "data" : {
    "dataValuesToGetWhenClickedOn" : 111,
    "notificationOptions" : {
      "id" : 4,
      "title" : "Title test",
      "text" : "Test message",
      "smallIcon" : "drawable/icon",
      "largeIcon" : "https://avatars2.githubusercontent.com/u/1174345?v=3&s=96",
      "autoCancel" : true,
      "vibrate": [200,300,200,300],
      "color": "0000ff",
      "headsUp": true,
      "sound": true
    }
  }
}

Or if you want more than one line of text when notification is "opened":

{
  "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
  "data" : {
    "dataValuesToGetWhenClickedOn" : 111,
    "notificationOptions" : {
      "id" : 4,
      "title" : "Title test",
      "textLines" : ["Message 1", "Message 2"],
      "summary" : "2 messages",
      "smallIcon" : "drawable/icon",
      "largeIcon" : "https://avatars2.githubusercontent.com/u/1174345?v=3&s=96",
      "autoCancel" : true,
      "vibrate": [200,300,200,300],
      "sound": true
    }
  }
}

Or if you want to show a big text when notification is "opened":

{
  "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
  "data" : {
    "dataValuesToGetWhenClickedOn" : 111,
    "notificationOptions" : {
      "id" : 4,
      "...": "...",
      "bigText": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris mollis urna sed nisl venenatis, a tincidunt orci iaculis. In hac habitasse platea dictumst. Nulla quis hendrerit risus. Morbi neque lectus, laoreet quis dui quis, luctus blandit mauris. Sed ullamcorper risus et lorem facilisis, sit amet tristique nulla rutrum. Vivamus auctor pulvinar ligula, tempor lacinia arcu commodo in. Ut condimentum dolor ac felis venenatis, sit amet cursus erat accumsan. Aliquam a justo elit. Maecenas dignissim suscipit ipsum, nec laoreet velit."
    }
  }
}

Or if you want to show a big picture when notification is "opened":

{
  "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
  "data" : {
    "dataValuesToGetWhenClickedOn" : 111,
    "notificationOptions" : {
      "id" : 4,
      "...": "...",
      "bigPicture": "https://cloud.githubusercontent.com/assets/7321362/24875178/1e58d2ec-1ddc-11e7-96ed-ed8bf011146c.png"
    }
  }
}

Or if you want to open the app when notification is received ⚠️DEPRECATED⚠️ :

{
  "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
  "data" : {
    "dataValuesToGetWhenClickedOn" : 111,
    "notificationOptions": {
      "id" : 4,
      "...": "...",
      "openApp": true
    }
  }
}

The openApp feature will not work on Android 10 due to added restrictions: https://developer.android.com/guide/components/activities/background-starts

Channels for Android 8+

From the version 1.9.0 on, it's possible to define in which notification channel the notification will be linked to:

{
  "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
  "data" : {
    "dataValuesToGetWhenClickedOn" : 111,
    "notificationOptions": {
      "id" : 4,
      "...": "...",
      "channelId": "music",
      "channelName": "Music",
      "channelDescription": "Notifications for new musics available"
    }
  }
}

Creating notifications locally

From the version 1.7.0 on, it's possible to "simulate" the extended Firebase support using the same options, called like:

FirebaseExtendedNotification.showNotification({
  "dataValuesToGetWhenClickedOn" : 111
}, {
  "title" : "Title test",
  "textLines" : ["Message 1", "Message 2"],
  "summary" : "2 messages",
  "..." : "..."
});

JSON.stringified notificationOptions

From the version 1.10.0 on, it's possible to send as string instead of object, called like:

{
  "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
  "data" : {
    "dataValuesToGetWhenClickedOn" : 111,
    "notificationOptions" : JSON.stringify({
      "id" : 4,
      "title" : "Title test",
      "text" : "Test message",
      "smallIcon" : "drawable/icon",
      "largeIcon" : "https://avatars2.githubusercontent.com/u/1174345?v=3&s=96",
      "autoCancel" : true,
      "vibrate": [200,300,200,300],
      "color": "0000ff",
      "headsUp": true,
      "sound": true
    })
  }
}

Observations:

  • At least for now, bigPicture, bigText and textLines are mutually exclusive.
  • To get the default vibration, use true instead of array.
  • To set a background color, use ARGB value as integer like 0x000000ff (less readable 255), or as string like "000000ff", with alpha, or "0000ff", without alpha, or for convenience "#0000ff".
  • For sound:
    • To play the default sound, use true;
    • To play a sound from resource, start with res://. For example res://raw/music_mp3 will play the R.raw.music_mp3 if available.
    • To play a sound from the web, start with http:// or https://. For example http://tindeck.com/download/pro/yjuow/Not_That_Guy.mp3 will download the file in cache and play it.

Make sure that in Android SDK Manager it is installed:

  • Android Support Library version 23 or greater
  • Android Support Repository version 20 or greater
  • Google Play Services version 27 or greater
  • Google Repository version 22 or greater