Firebase Notifications is a free service that enables targeted user notifications for mobile app developers.
Built on Firebase Cloud Messaging and the FCM SDK, Firebase Notifications (Notifications) provides an option for developers and organizations seeking a flexible notification platform that requires minimal coding effort to get started, and a graphical console for sending messages. Using the Notifications console GUI, you can reengage and retain your user base, foster app growth, and support marketing campaigns.
Reference: Firebase Cloud Messaging
First Create project on console firebase
Download google-services.json file on firebase console and add "platform/android" path.
###Like below image :
=============
cordova plugin add https://github.com/LokeshPatel/Cordova-Plugin-FCMNotification.git
cordova plugin add Cordova-Plugin-FCMNotification -- Search local path
Steps:
1.) Open file "build.gradle" (Path : platform > android > build.gradle)
2.) find "buildscript" text in "build.gradle" file.
3.) There you will find one classpath line, after that line, please add this line :
classpath 'com.google.gms:google-services:3.0.0'
###Like below image :
4.) then find "dependencies" (Select that dependencies where you have text "compile" and where that dependencies is getting ended, just after that, add this line :
apply plugin: 'com.google.gms.google-services'
###Like below image :
navigator.FCMNotification.fcmTokenID(function(tokenID){
// retrun token id for notification service
console.log("Token ID = " + tokenID);
//Token ID use for call notification form FCM server.
}, function(error){
console.log(error);
});
navigator.FCMNotification.fcmReadAllMessages(function(result){
/* Return all message in json formate with id and message */
console.log(result);
},function(e){console.log(e)}
);
/* Result format : {"msg_1":"Hello World One !","msg_2":"Hello World Two!","msg_3":"Hello World Three!","totalCount":3} */
navigator.FCMNotification.fcmClearAllMessages(function(result){
console.log(result);
}, function(error){
console.log(error);
});
navigator.FCMNotification.fcmClearByMessagesId(function(result){
console.log(result);
}, function(error){
console.log(error);
},"msg_1");
/* Message get from local store list */
Reference: Firebase Cloud Messaging