cordova-plugin-firebase-extended-notification
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:
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": 200300200300 "color": "0000ff" "headsUp": true "sound": true
Or if you want more than one line of text when notification is "opened":
Or if you want to show a big text when notification is "opened":
Or if you want to show a big picture when notification is "opened":
Or if you want to open the app when notification is received ⚠️DEPRECATED⚠️ :
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:
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;
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
Observations:
- At least for now,
bigPicture
,bigText
andtextLines
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 readable255
), 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 exampleres://raw/music_mp3
will play theR.raw.music_mp3
if available. - To play a sound from the web, start with
http://
orhttps://
. For examplehttp://tindeck.com/download/pro/yjuow/Not_That_Guy.mp3
will download the file in cache and play it.
- To play the default sound, use
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