【发布时间】:2019-04-11 00:44:05
【问题描述】:
我使用 Visual Studio Code 创建了一个 cordova 项目。我正在使用这个插件: phonegap-plugin-push 我已按照说明进行操作。
我需要使用通知。我正在使用 Firebase,我已经下载了 google-services.json,将它放在我的根目录中,在 Android 上运行并通过 Firebase 云消息传递进行了测试。一切正常。
问题:iOS。我已经下载了 GoogleService-Info.plist,放在我的根项目和根平台 ios 上。 从苹果开发者控制台下载 p8 证书并放到 Firebase 控制台:
所以,当我在 index.js 上启动它时,ondeviceready:
onDeviceReady: function() {
this.receivedEvent('deviceready');
//alert("ciao");
app.push = PushNotification.init({
"android": {
"senderID": "xxxx"
},
"ios": {
"senderID": "xxxx",
"sound": true,
"vibration": true,
"badge": true
},
"windows": {}
});
app.push.on('registration', function(data) {
alert(data.registrationId);
console.log("registration event: " + data.registrationId);
document.getElementById("regId").innerHTML = data.registrationId;
var oldRegId = localStorage.getItem('registrationId');
if (oldRegId !== data.registrationId) {
// Save new registration ID
localStorage.setItem('registrationId', data.registrationId);
// Post registrationId to your app server as the value has changed
}
});
app.push.on('notification', function(data) {
console.log('notification event');
alert("qualcosa ricevuto: " + data.message + data.title);
});
app.push.on('error', function(e) {
//console.log("push error = " + e.message);
alert("push error = " + e.message);
});
}
我在我的 iOS 设备(iPad 和 iPhone)上收到了令牌,但是当我尝试从 Firebase 测试它时,我看不到我的设备注册的令牌。 为什么?我做错了什么?
【问题讨论】:
-
您解决了这个问题吗? Pushnotification 对我来说是未定义的。请发布您的解决方案。
-
没有还是不行,我用原生编程改了
标签: ios firebase cordova firebase-cloud-messaging phonegap-plugins