Using cordova plugin ktekosi-phonegap-plugin-push
, I get the registrationID
var push = PushNotification.init({ "android": {"senderID": "my sender ID"}});
push.on('registration', function(data) {
console.log(data.registrationId);
document.getElementById("fcm_id").innerHTML = data.registrationId;
});
So I can use it by the server to send notification through FCM.
How can I get this registrationID
fixed for all time? Is this an app specific ID or a user specific ID?
Push registration ID will be changed with time. This is an usual case. This is neither an instance of the installed application nor app-specific or user-specific id.
When an app comes online you need to fetch the push registration ID and then pass it to your backend server each time to keep your backend server updated with the push registration ID.
Your backend server will then generate a push notification and will send it to FCM with the specific push registration ID it has. FCM then manages receiving the push notification in your mobile application.
I've answered a question here telling how push notification system works. You might have a look.
Update
Looks like google has changed its new gcm library as the answer stated here - https://stackoverflow.com/a/16839326/3145960. You might take a look at here. So, as I've read, the push registration id is updated only when app receives an update or the android os gets updated. Its much simpler now.