简体   繁体   English

PhonegapPluginPush - 获取“OK”作为推送数据

[英]PhonegapPluginPush - getting "OK" as push data

We're trying to get data from a push when the application is killed.当应用程序被终止时,我们试图从推送中获取数据。

Here a stack info:这里有一个堆栈信息:

Android: 8
device: Xiaomi Redmi 5
cordova: 7.1.0
cordova-android: 6.4.0
phonegap-plugin-push: 2.1.2

Registration and Handlers Set注册和处理程序集

user registers FCM token and exec.用户注册FCM令牌和 exec。 the following code.以下代码。 Finally最后

push.on('notification', (data) => { 
   .... statement_1
    callbackA(data); 
})

push.subscribe('notification', (data) => { 
   .... statement_2
   // This statement is called only if 
   //   app is closed and the user taps 
   //   onto notification in the shade 
})

We are registering and subscribing to on the same 'notification' event due to a problem with Android / App Closed.由于 Android / App Closed 的问题,我们正在注册和订阅同一个“通知”事件。 ( Normally, 'notification' event is not triggered if user tap on the notification when the app is killed -- see https://github.com/phonegap/phonegap-plugin-push/issues/2859 ) (通常,如果用户在应用程序被终止时点击通知,则不会触发“通知”事件 - 请参阅https://github.com/phonegap/phonegap-plugin-push/issues/2859

server push request example服务器推送请求示例

{
  "registration_ids" : [ "...." ],
  "priority" : 5,
  "data" : {
    "title" : "Push with URL",
    "message" : "Questo invece è un esempio di push con un URL ",
    "purpose" : "NEWS",
    "id" : "2",
    "notId" : 5,
    "url" : "https://www.ciao.it/",
    "actions":[
         {
            "title":"Accept",
            "callback":"show",
            "foreground":true
         }
      ]
  }
}

Problem is that now, the event is triggered correctly, but plugin pass ad data 'OK' string instead push data for both statements (1-2).问题是现在,事件被正确触发,但插件传递广告数据“OK”字符串而不是推送两个语句(1-2)的数据。

What's wrong??怎么了??

( FYI : Normal scenarios [background, foreground] are working like a charm! ) 仅供参考:正常场景[背景,前景]就像一个魅力!)

Super thanks in advance超级感谢提前

We solve considering the ADB logcat.我们解决考虑 ADB logcat。

In the app re-open process, it's clear that the listener was registered after the plugin's intent is processed.在app重新打开的过程中,很明显监听器是在插件的intent处理完之后注册的。

So, as the first rows of the main ".run" module statement, we put the following code所以,作为主“.run”模块语句的第一行,我们把下面的代码

$ionicPlatform.ready(function() {
    if (ionic.Platform.isAndroid()) {
      var push = PushNotification.init({
        android: {}
      });
      push.on("notification", function(data) {
        $$PushManager.init(data);
      });
    }
  });

With the above rows, we are able to treat push with the service in charge of that.有了上面的行,我们就可以用负责它的服务来处理推送。

Simon西蒙

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

相关问题 在ngCordova / Ionic中推送通知,只需“确定”即可 - Push notifications in ngCordova/Ionic, getting just “OK” 在 onMessageReceived 中获取推送通知数据但不显示推送通知 - Getting Push Notification Data in onMessageReceived but not showing Push Notification 通过GCM推送通知获取错误的数据 - Getting wrong data throug GCM push notification 通过获取推送通知分段更新数据 - Update data in fragment with getting push notification GCM Android推送通知:发送确定但未送达 - GCM Android Push Notification: send OK but not delivered 使用listpreference并获取密钥有效,但没有确定按钮 - Using listpreference and getting the key works but no ok button GCM推送通知注册呼叫返回确定,但设备未注册 - GCM Push Notification registration call returns ok but device is not registered DatePickerDialog确定按钮未获取所选日期 - DatePickerDialog OK button not getting the selected date 尽管Firebase参考可以,但出现null错误- - Getting null error although firebase reference is ok - Android:获得响应“200 ok”但 Retrofit 失败 - Android : Getting response “200 ok” but Retrofit fails
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM