Expected Behaviour
Unable to send push notifiction to browser. For example
{
multicast_id: 3474356041305334000,
success: 1,
failure: 0,
canonical_ids: 0,
results: [ { error: null } ]
}
Actual Behaviour
I am getting this :
{
multicast_id: 3474356041305334000,
success: 0,
failure: 1,
canonical_ids: 0,
results: [ { error: 'InvalidRegistration' } ]
}
Reproduce Scenario (including but not limited to)
Every time.
Steps to Reproduce
Add push functionality in ionic app:
import { Push, PushObject, PushOptions } from '@ionic-native/push/ngx';
pushObject;
constructor(
public alertController: AlertController,
private push: Push,
) {
}
setupPush() {
this.pushObject = this.push.init({
android: {
},
browser: {
pushServiceURL: 'http://push.api.phonegap.com/v1/push',
},
ios: {
alert: "true",
badge: "false",
sound: "true"
},
windows: {}
});
console.log("Push Init Called");
this.pushObject.on('registration').subscribe((data: any) => {
console.log('device token -> ' + data.registrationId);
});
this.pushObject.on('error').subscribe(error => console.error('Error with Push plugin' + error));
}
Platform and Version (eg. Android 5.0 or iOS 9.2.1)
Firefox 77.0.1
Cordova CLI version and cordova platform version
cordova --version 9.0.0 (cordova-lib@9.0.1)
cordova platform version browser 6.0.0
Plugin version
phonegap-plugin-push 2.3.0 "PushPlugin"
Sample Push Data Payload
var gcm = require('node-gcm');
var sender = new gcm.Sender(firebaseKey);
module.exports = {
sendPush(deviceIds, title, body) {
var message = new gcm.Message();
message.addNotification({
title: 'Alert!!!',
body: 'Abnormal data access',
icon: 'ic_launcher'
});
// Actually send the message
sender.send(message, { registrationTokens: deviceIds }, function (err, response) {
if (err) console.error(err);
else console.log(response);
});
},
};
Sample Code that illustrates the problem
{
multicast_id: 1564376416527500000,
success: 0,
failure: 1,
canonical_ids: 0,
results: [ { error: 'InvalidRegistration' } ]
}