[英]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.