简体   繁体   中英

Worklight app crashes when receiving push notification

Hi I have developed a Worklight application for android which uses Bluemix IBM Push, when I receive the notification, if the app is closed, it works fine and opens the app, but when the app is open the app crashes with the following error.

10-09 18:13:00.676: E/AndroidRuntime(4665): FATAL EXCEPTION: main
10-09 18:13:00.676: E/AndroidRuntime(4665): java.lang.ClassCastException: com.ibm.mobile.services.push.internal.InternalPushMessage cannot be cast to com.worklight.androidgap.push.GCMIntentService$Message
10-09 18:13:00.676: E/AndroidRuntime(4665):     at com.worklight.androidgap.plugin.Push.onNewIntent(Push.java:193)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at org.apache.cordova.PluginManager.onNewIntent(PluginManager.java:371)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at org.apache.cordova.CordovaWebView.onNewIntent(CordovaWebView.java:874)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at org.apache.cordova.CordovaActivity.onNewIntent(CordovaActivity.java:702)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1225)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at android.app.ActivityThread.deliverNewIntents(ActivityThread.java:2472)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at android.app.ActivityThread.performNewIntents(ActivityThread.java:2485)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at android.app.ActivityThread.handleNewIntent(ActivityThread.java:2494)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at android.app.ActivityThread.access$1400(ActivityThread.java:165)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1444)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at android.os.Handler.dispatchMessage(Handler.java:107)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at android.os.Looper.loop(Looper.java:194)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at android.app.ActivityThread.main(ActivityThread.java:5391)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at java.lang.reflect.Method.invokeNative(Native Method)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at java.lang.reflect.Method.invoke(Method.java:525)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
10-09 18:13:00.676: E/AndroidRuntime(4665):     at dalvik.system.NativeStart.main(Native Method)
10-09 18:13:00.677: D/WLClient(4665): WLClient$ActivityListener.onActivityPaused in WLClient.java:1155 :: on activity paused com.Techathon.Techathon . activity count = 0
10-09 18:13:00.683: D/NONE(4665): Flush called
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665): Logger$UncaughtExceptionHandler.uncaughtException in Logger.java:402 :: Uncaught Exception
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665): java.lang.ClassCastException: com.ibm.mobile.services.push.internal.InternalPushMessage cannot be cast to com.worklight.androidgap.push.GCMIntentService$Message
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at com.worklight.androidgap.plugin.Push.onNewIntent(Push.java:193)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at org.apache.cordova.PluginManager.onNewIntent(PluginManager.java:371)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at org.apache.cordova.CordovaWebView.onNewIntent(CordovaWebView.java:874)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at org.apache.cordova.CordovaActivity.onNewIntent(CordovaActivity.java:702)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at android.app.Instrumentation.callActivityOnNewIntent(Instrumentation.java:1225)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at android.app.ActivityThread.deliverNewIntents(ActivityThread.java:2472)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at android.app.ActivityThread.performNewIntents(ActivityThread.java:2485)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at android.app.ActivityThread.handleNewIntent(ActivityThread.java:2494)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at android.app.ActivityThread.access$1400(ActivityThread.java:165)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1444)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at android.os.Handler.dispatchMessage(Handler.java:107)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at android.os.Looper.loop(Looper.java:194)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at android.app.ActivityThread.main(ActivityThread.java:5391)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at java.lang.reflect.Method.invokeNative(Native Method)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at java.lang.reflect.Method.invoke(Method.java:525)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
10-09 18:13:00.718: E/com.worklight.common.Logger$UncaughtExceptionHandler(4665):   at dalvik.system.NativeStart.main(Native Method)
10-09 18:13:02.586: I/Process(4665): Sending signal. PID: 4665 SIG: 9

I have setup my enviroment according the link provided here http://mbaas-gettingstarted.ng.bluemix.net/hybrid

Have you tried editing your AndroidManifest.xml to remove the references to GCMIntentService?

You might be able to comment out the sections as explained here: https://developer.ibm.com/answers/questions/19343/double-push-notifications/?smartspace=bluemix

That way you will be only using the Bluemix Push SDK to respond to push notifications. Hopefully avoiding that error entirely.

EDIT : After some playing around I figured out that the Push plugin was to blame for the conflicting SDKs. After I commented out the Worklight Push plugin in the config.xml the error disappeared.

Comment these lines and try again:

<feature name="Push">
     <param name="android-package" value="com.worklight.androidgap.plugin.Push" />
</feature>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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