Push Notifiaction With Firbase

Posted By : Arun Kataria | 28-May-2018

FCM stand for Firebase Cloud Messaging, is a cross-platform message, which alow you safe and secure sending messages.

Using Firebase Cloud Messaging, We can send message to drive user reinstatement and retention. we can tell client app that email or other data is applicable to synchronize.  For use-cases such as quick messaging, The message can send a load of up to 4KB to a client app.

FCM working Diagram:

Setup of FCM on Ionic:

1. You need to create the account in https://firebase.google.com/ and create your project in your account.
2. Give name of the package for your project (mine is info.ionicproject.firebase) which is to be integrate with Firebase. 
3. Now go to the Project overview and then project setting download google-service.json file and place in project root directory.

 

4. Now install cordova plugin :-  

cordova plugin add cordova-plugin-fcm

5. Below is the code to get Device ID:

 window.FirebasePlugin.getToken(function (token) {
            // console.log("token==2", token);
          
          }, function (error) {
            console.error(error);
          });

6. And Below is the code to receive Push Notification.

window.FirebasePlugin.onNotificationOpen(function (notification) {
         
          alert(notification.body)
          
        }, function (error) {
          console.error(error);
        });

 

About Author

Author Image
Arun Kataria

Arun has good skills in AngularJS, NodeJS, MongoDB and many more. He is highly motivated which allow him to strive for proficiency when accomplishing assigned duties. He is an excellent team operative.

Request for Proposal

Name is required

Comment is required

Sending message..