plug phonegap-plugin-push to Firebase



很快我的环境: 电话差距 8.0.0 Phonegap-plugin-push 2.1.2(最新版本与PhoneGap 8.0.0不兼容(

当时:

  • 我设法通过电话间隙模拟器中的"phonegap推送"接收从本地机器生成的推送通知
  • 我无法在电话间隙模拟器中收到来自Firebase的推送通知(可能吗?
  • 当我为 Android 构建应用程序时,由于我的应用程序中的 phonegap-plugin-push 关联代码,她在启动时崩溃(空白页((如果我评论它,她会正常启动(

我的代码(VueJS 框架(

console.log('calling push init');
window.gtvapp.push = PushNotification.init({
'android': {
// 'senderID': 'XXXXXXXX'
},
'browser': {},
'ios': {
'sound': true,
'vibration': true,
'badge': true,
'alert': true
// 'senderID': 'xxxxxxxx'
},
'windows': {}
})
console.log('after init')
window.gtvapp.push.on('registration', function(data) {
console.log('registration event: ' + data.registrationId)
var oldRegId = window.localStorage.getItem('registrationId')
if (oldRegId !== data.registrationId) {
window.localStorage.setItem('registrationId', data.registrationId)
// Post registrationId to your app server as the value has changed
// TODO
}
})
window.gtvapp.push.on('error', function(e) {
console.log('push error = ' + e.message)
})

//(...

let router = this.$router
window.gtvapp.push.on('notification', function(data) {
console.log('notification event')
console.log(JSON.stringify(data))
if (device.platform === 'Android') {
navigator.notification.alert(
data.message,         // message
function() {
console.log(window.location.pathname)
console.log(data.additionalData.path)
// window.localStorage.setItem('pushpath', data.additionalData.path)
router.push(data.additionalData.path)
},
data.title,
'En savoir plus'
)
}
})

此代码在模拟器"phonegap serve"+本地推送通知如果"phonegap push"上完美运行

问题:

  • 第 1 步:理论上是否可以在"phonegap 服务实例"中接收 Firebase 通知
  • 第 2 步:只需"Google-Services.json"文件即可正确配置 Firebase 注册

多谢

步骤 1:理论上是否可以在"phonegap 服务实例"中接收 Firebase 通知

不,不是,您必须构建应用程序并在设备上安装 apk

第 2 步:只需"Google-Services.json"文件即可正确配置 Firebase 注册

是的。 只是关于电话差距8的事情:

<platform name="android">
<resource-file src="google-services.json" target="app/google-services.json" />
</platform>

"app/"很重要。

最新更新