Hi,
I updated to your new version of your tutorial. I see you have updated it to use: "https://fcm.googleapis.com/fcm/send"
. Thank you.
I have implemented exactly as your instructions say as far as I know.
Installed the plugin:
ionic plugin add https://github.com/phonegap/phonegap-plugin-push --variable SENDER_ID=”XXXXXXXXXXX”
package.json
"cordovaPlugins": [
"cordova-plugin-device",
"cordova-plugin-console",
"cordova-plugin-whitelist",
"cordova-plugin-splashscreen",
"cordova-plugin-statusbar",
"ionic-plugin-keyboard",
{
"variables": {
"SENDER_ID": "XXXXXXXXXXX"
},
"locator": "phonegap-plugin-push",
"id": "phonegap-plugin-push"
}
],
"cordovaPlatforms": []
registration
let push = Push.init({
android: {
senderID: "XXXXXXXXXXX"
},
ios: {
alert: "true",
badge: false,
sound: "true"
},
windows: {}
});
push.on('registration', (data) => {
let promise: Promise<string> = this.notificationService.push(data.registrationId, topics[0], message, this.activeChat.title); // <== calls the Java server
promise.then((data) => {
alert('push: data = ' + data);
//return;
});
});
I get the Java Server to push the message:
{"data":{"title":"title","message":"Test"},"to":"dvpiJM32QwE:APA91bECzkuTUHYtpZN3OFrq6xOWep_twj3mN1TcI0F0DaKY92Rp8gwHz2Z-U1HI1_EA_Jp0Hu2zGBw1sKhxqrZUlmTUWnXHG8v0J66HXm7Nw9yPSKep9b_TGQ0SNT8cDEmFoZgpu5lo"}
[stdout] (default task-6) 200
[stdout] (default task-6) OK
However, my Android App is not receiving it.
notification
app.ts
let push = Push.init({
android: {
senderID: "XXXXXXXXXXX"
},
ios: {
alert: "true",
badge: false,
sound: "true"
},
windows: {}
});
push.on('notification', (data) => {
alert('Received Notification!!! message = '+data.message);
});
push.on('error', (e) => {
alert('Error: '+e.message);
console.log(e.message);
});
The alert('Received Notification!!! message = '+data.message);
is not being triggered and my device does not receive a notification.
Do you know what I am doing incorrectly?
Thanks