【问题标题】:cordova firebase plugin for ios 10 +适用于 ios 10 + 的科尔多瓦 firebase 插件
【发布时间】:2017-05-03 05:03:34
【问题描述】:

我想在 iOS cordova 应用中实现 firebase 云消息传递。

我试过cordovan-plugin-fcm插件 它适用于 iOS 9,但不适用于 iOS 10。

我的问题是哪个是实现推送通知的最佳 cordova firebase 插件?是 iOS 9 还是 10?

【问题讨论】:

    标签: ios cordova firebase firebase-cloud-messaging


    【解决方案1】:

    尝试实现这一点。 https://github.com/fechanique/cordova-plugin-fcm

    然后从您的 Firebase 帐户,尝试发送通知。它会起作用的。

    【讨论】:

    • 嗨,我已经实现了这个插件,它在 ios 9 中工作,而不是在 10 中
    • iOS 10 中到底发生了什么?如果您遇到错误,可以告诉我吗?
    • 没有收到任何错误,没有收到推送通知/是否需要任何本机代码,因为我不是 ios 开发人员?
    • 你能举例说明吗?
    • 你得到设备令牌了吗?
    【解决方案2】:

    我试试这个,它适用于带有 ios 9.3 的模拟器,但如果在带有 ios 10.3 的模拟器上尝试相同,则没有消息。 这是我的代码:

        FCMPlugin.getToken(function(token){
        if ( device.platform == 'android' || device.platform == 'Android' || device.platform == "amazon-fireos" ){
            sendPushRegistration(token, 'android');
        } else {
            sendPushRegistration(token, 'ios');
        }
      });
    
      FCMPlugin.onTokenRefresh(function(token){
        if ( device.platform == 'android' || device.platform == 'Android' || device.platform == "amazon-fireos" ){
            sendPushRegistration(token, 'android');
        } else {
            sendPushRegistration(token, 'ios');
        }
      });
    
      FCMPlugin.onNotification(function(data){
        alert('onNotification');
        if(data.wasTapped){
          //Notification was received on device tray and tapped by the user.
          alert( JSON.stringify(data) );
        }else{
          //Notification was received in foreground. Maybe the user needs to be notified.
          alert( JSON.stringify(data) );
        }
     });
    

    我在 getToken 函数中得到一个令牌。但是在 ios 10.3 中没有调用 onNotification 函数,在 ios 9.3 中它可以工作。 插件是cordova-plugin-fcm 2.1.2“FCMPlugin”,消息由firebase控制台发送到一台设备。

    【讨论】:

      猜你喜欢
      • 2016-08-30
      • 2017-01-27
      • 1970-01-01
      • 1970-01-01
      • 2015-09-08
      • 2015-10-13
      • 1970-01-01
      • 1970-01-01
      • 2015-05-19
      相关资源
      最近更新 更多