//推送点击事件
plus.push.addEventListener( "click", function ( msg ) {
// 分析msg.payload处理业务逻辑
plus.nativeUI.alert( "You clicked: " + toString(msg) );
}, false );
//推送接收事件
plus.push.addEventListener( "receive", function ( msg ) {
// 分析msg.payload处理业务逻辑
plus.nativeUI.alert( "You received: " + toString(msg) );
}, false );
两个监听都添加的话,在接收到推送消息时收不到receive回调,在点击通知栏消息时可以收到receive回调,收不到click回调;
只添加receive监听时,在接收到推送消息时收不到receive回调,在点击通知栏消息时可以收到receive回调;
只添加click监听时,在接收到推送消息时收不到receive回调,在点击通知栏时程序停止运行后台报错,错误附后
我采用的本地打包,测试机型 mi2 不知道其他朋友有没有遇到这种情况/kb
望版主回复
12-24 17:28:39.575 28619-28619/com.xxxx.xxxx E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.xxxx.xxxx, PID: 28619
java.lang.RuntimeException: Unable to start receiver io.dcloud.feature.apsGt.PushMessageReceiver: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.util.ArrayList.size()' on a null object reference
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2589)
at android.app.ActivityThread.access$1700(ActivityThread.java:147)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1360)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5235)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:906)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:701)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.util.ArrayList.size()' on a null object reference
at io.dcloud.feature.aps.a.b(PushManager.java:365)
at io.dcloud.feature.aps.APSFeatureImpl.execScript(APSFeatureImpl.java:117)
at io.dcloud.feature.apsGt.PushMessageReceiver.onReceive(PushMessageReceiver.java:84)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2582)
at android.app.ActivityThread.access$1700(ActivityThread.java:147)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1360)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5235)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:906)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:701)
4***@qq.com
您好,请问您这个问题解决了吗,我也是同样的问题
2017-12-05 20:35