Push Notification with Firebase
Push Notification allows the developer to notify the all user at any time, a user has an app will receive them. push Notification can be implemented in (android, ios, windows) with ionic Push plugin.Firebase Cloud messaging
Firebase is used to create a device token and server key, Go to firebase console, create a new project and select the setting.In that project, a user gets the sender Id and server key to set push notification.
Step-1
Goto project setting, and Add firebase to android app, To register an Android app, copy the package name in config.xml and set it.
step-2
Download the google-service.JSON file and move the google-service.JSON into the app-module project directory and click finish.
Install Push plugin
Install ionic native push plugin, for register and receiving notification. replace the sender-id with the push option in SENDER-ID.
ionic cordova plugin add phonegap-plugin-push --variable SENDER-ID=xxxxx
npm install --save @ionic-native/push
Import
Import the push plugin in app-module and then use it in app-component.
import { Push, PushObject, PushOptions } from '@ionic-native/push';
const options: PushOptions = {
android: {
senderID: 'xxxxxxxxx'
},
ios: {
alert: 'true',
badge: true,
sound: 'false'
},
windows: {},
};
const pushObject: PushObject = this.push.init(options);
pushObject.on('notification').subscribe((notification: any) => {
if (notification.additionalData.foreground) {
let youralert = this.alertCtrl.create({
title: 'New Push notification',
message: notification.message
});
youralert.present();
}
});
pushObject.on('registration').subscribe((registration: any) => console.log('Device registered', registration));
pushObject.on('error').subscribe(error => console.error('Error with Push plugin', error));
Now test the push Plugin, by push sample message from firebase and notification display in mobile.
when opening it, it displays in the app.
9 Comments
ReplyDeleteGood Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging
ionic training in chennai
Useful blog, keep sharing with us.
ReplyDeleteIonic Training in Chennai
Ionic Online Training
Nice blog. It is very helpful.
ReplyDeleteJava Training Institute in Chennai
Learn Java Online
Java Training Institutes in Bangalore
Thanks for sharing valuable information,
ReplyDeleteGraphic Design courses in Chennai
Online Graphic Design Course
Graphic Design Courses In Bangalore
Great post and thanks for sharing.
ReplyDeleteAlso visit:
Python Course In Madurai
Python Training In Pune
Python Training In Hyderabad
Python Training In Gurgaon
Nice Post!!! gratitude for imparting this post to us.
ReplyDeleteAndroid Training in Chennai
Android Course Online
Android Training in Bangalore
When your successful streak stops, resume your initial minimal wager until the desk goes sizzling again. The casino's biggest benefit (the "home edge") is that the participant has to behave first. If a participant "busts" , the casino immediately takes the participant's 토토사이트 cash. If the casino then "busts" on the same hand, the participant nonetheless loses.
ReplyDeleteI got some valuable points through this blog. csgo ranked accounts
ReplyDeleteA platform for cloud computing called Amazon Web Services offers users a variety of cloud services. AWS (Amazon Web Services) can be characterised as a safe platform for cloud services that provides computing power, database storage, content distribution, and a number of other features.
ReplyDeleteAWS Training in Chennai
AWS Training in Bangalore
AWS Course in Coimbatore