How to push notification to specfic users | ionic 2 firebase?


#1

if i use ionic 2 to build my university app , and if i want to push notifiction to specfic users . and i use firebase as a full backend .
my app is build for education purpose , it for university , i want to push notification to First year students based on their ids , or Based on value on the database like {studentIn:1} . i wont to send notification to all app devices ? any solution or help?


#2

I’d do something like this:

let push = PushNotification.init({
android: {
senderID: “12345679”
},
ios: {
alert: “true”,
badge: true,
sound: ‘false’
},
windows: {}
});

push.on(‘registration’, (data) => {
this.profiledata.UpdateNotificationKey(data.registrationId);
});

To save the key in firebase using the Firebase SDK. That line would resemble the path to the user profile data in any provider you may have.

Your Update NotificationKey() would look like this:

updateNotificationKey(newRegistration: any):any{
this.userProfile.child(this.currentUser.uid).update({
Notificationkey: newRegistration
})
}

(This is all I can think of in terms of saving the User notification key onto the database. Once it’s on the database you can do anything with it. Sadly I don’t know how to send notifications from the app…


#3

Hi, did you figure out how to make this work? I am trying to implement similar things. Thanks in advance.