简体   繁体   English

适用于iOS 10的cordova firebase插件

[英]cordova firebase plugin for ios 10 +

I want to implement firebase cloud messaging in iOS cordova app. 我想在iOS Cordova应用中实现Firebase云消息传递。

I tried cordovan-plugin-fcm plugin It works in iOS 9 but not working with iOS 10. 我尝试了cordovan-plugin-fcm插件它可以在iOS 9中使用,但不能在iOS 10中使用。

My question is which was the best cordova firebase plugin to implement push notification? 我的问题是实现推送通知的最佳Cordova Firebase插件是哪个? Is it iOS 9 or 10? 是iOS 9还是10?

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

Then from your firebase account, Try to send notifications. 然后从您的Firebase帐户尝试发送通知。 It will work. 它会工作。

I try this and it works on simulator with ios 9.3 but if if try the same on simuator with ios 10.3 there is no message. 我尝试这样做,它可以在ios 9.3的模拟器上运行,但是如果在ios 10.3的模拟器上尝试相同的操作,则不会显示任何消息。 This is my code: 这是我的代码:

    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) );
    }
 });

I get a token in the getToken function. 我在getToken函数中得到一个令牌。 But the onNotification function isn`t called in ios 10.3, in ios 9.3 it works. 但是在iOS 10.3中没有调用onNotification函数,在iOS 9.3中它可以工作。 Plugin is cordova-plugin-fcm 2.1.2 "FCMPlugin" and the message was send by firebase console to one device. 插件为cordova-plugin-fcm 2.1.2“ FCMPlugin”,并且该消息已通过Firebase控制台发送到一台设备。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM