我正在尝试将 Push Notification 用于我的移动应用程序,并尝试使用Ionic IO Push,PushWoosh,现在OneSignal,两者都存在同样的问题 .
在One Signal documentation about push notification not being sent中,它表示应用程序可能处于 Force Closed 状态,如果是,则在 logcat
中,您将在尝试发送推送通知时看到此消息:
W / GCM-DMM:广播意图回调:result = CANCELED forIntent {act = com.google.android.c2dm.intent.RECEIVE pkg = com.onesignal.example(has extras)}
所以,为了看到它,我使用命令 adb logcat grep | 'GCM'
来查看我的设备是否正在发送此消息 .
是的,确实如此 .
如果应用程序是 Forced Closed ,则可以显示它,但是当应用程序是 Open 或 Background 时也会显示错误消息 .
我发现它很奇怪,因为当应用程序处于打开状态时,或者在后台时,我可以接收推送通知,并按照我的意愿处理它,即使错误消息显示在 logcat
中,但是当我关闭它时,没有更多的通知,错误消息一直出现在 logcat
中 .
我试过了什么?
-
在同一个One signal documentation about push notification not being sent中,它表示该应用程序可以 Force Closed 与
Swiping away your app while remote debugging it
,所以我尝试使用ionic cordova run android --prod --release --device
来测试推送通知,但仍然发生了同样的事情 . -
OneSignal有lot of different configuration to send push messages,因此我在发送推送通知时尝试了许多不同的配置变体,其中任何一个都可以在应用程序关闭的情况下到达我的设备,甚至更改
logcat
消息 . -
在One signal instructions,Ionic instructions之后的应用程序中安装了OneSignal,并且,由于我非常绝望,所以也应用了Gradle config of Android SDK,但没有一个能够正常工作 .
我的配置
-
配置:
-
离子CLI:3.6.0
-
Cordova CLI:6.5.0
-
@ ionic-native / onesignal:4.1.0
-
设备:联想K5
-
插件列表
-
ionic cordova plugin list
-
cordova-plugin-app-event 1.2.0 "Application Events"
-
cordova-plugin-autostart 2.0.1 "Autostart"
-
cordova-plugin-console 1.0.7 "Console"
-
cordova-plugin-device 1.1.6 "Device"
-
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
-
cordova-plugin-statusbar 2.2.3 "StatusBar"
-
cordova-plugin-whitelist 1.3.2 "Whitelist"
-
de.appplant.cordova.plugin.local-notification 0.8.5 "LocalNotification"
-
ionic-plugin-keyboard 2.2.1 "Keyboard"
-
onesignal-cordova-plugin 2.1.2 "OneSignal Push Notifications"