phonegap、firebase、推送通知
我无法从Firebase获取要显示的通知。我遵循提供的教程。有什么问题吗phonegap、firebase、推送通知,firebase,notifications,push,phonegap,Firebase,Notifications,Push,Phonegap,我无法从Firebase获取要显示的通知。我遵循提供的教程。有什么问题吗 сode example : setupPush: function() { var push = PushNotification.init({ "android": { "senderID": "966613396976", "sound": true,
сode example :
setupPush: function() {
var push = PushNotification.init({
"android": {
"senderID": "966613396976",
"sound": true,
"vibration": true,
"badge": true
},
"browser": {},
"ios": {
"sound": true,
"vibration": true,
"badge": true
},
"windows": {}
});
push.on('registration', function(data) {
test(data);
var oldRegId = localStorage.getItem('registrationId');
if (oldRegId !== data.registrationId) {
localStorage.setItem('registrationId', data.registrationId);
}
});
push.on('error', function(e) {
console.log("push error = " + e.message);
});
push.on('notification', function(data) {
console.log('notification event');
navigator.notification.alert(
data.message, // message
null, // callback
data.title, // title
'Ok' // buttonName
);
});
}
};
看起来您使用的是已弃用版本的Phonegap推送插件。 有关较新版本,请参见此位置: 这意味着init函数应该如下所示:
const push = PushNotification.init({
android: {
vibrate: true,
sound: true
},
ios: {
fcmSandbox: false,
alert: true,
vibrate:true,
badge: true,
sound: true
}
});
请注意,android中没有使用“badge”参数。
此外,您还必须设置正确的config.xml文件:
这应该在那里:
<platform name="android">
<resource-file src="google-services.json" target="/google-services.json" />
</platform>
<platform name="ios">
<resource-file src="push/GoogleService-Info.plist" />
</platform>
<plugin name="phonegap-plugin-push" spec="2.0.0" source="npm" />
这仅适用于正确的版本:
您能就答案给出反馈吗?