hansemannn / titanium-firebase-cloud-messaging

Use the Firebase Cloud Messaging SDK in Axway Titanium 🚀 Edit
Other
43 stars 31 forks source link

Android: crash if the module is not yet initialized but onTokenRefresh event is called #29

Closed gaspardle closed 6 years ago

gaspardle commented 6 years ago

Crash on this line: https://github.com/hansemannn/titanium-firebase-cloud-messaging/blob/master/android/src/firebase/cloudmessaging/CloudMessagingModule.java#L142

Process: com.communauto.reservauto, PID: 24871
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean org.appcelerator.kroll.KrollObject.hasListeners(java.lang.String)' on a null object reference
    at org.appcelerator.kroll.KrollProxy.hasListeners(KrollProxy.java:999)
    at firebase.cloudmessaging.CloudMessagingModule.onTokenRefresh(CloudMessagingModule.java:111)
    at firebase.cloudmessaging.TiFirebaseInstanceIDService.onTokenRefresh(TiFirebaseInstanceIDService.java:18)
    at com.google.firebase.iid.FirebaseInstanceIdService.zza(Unknown Source:71)
    at com.google.firebase.iid.FirebaseInstanceIdService.handleIntent(Unknown Source:158)
    at com.google.firebase.iid.zzc.run(Unknown Source:4)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
    at java.lang.Thread.run(Thread.java:764)
m1ga commented 6 years ago

Thanks. The error looks like its coming from an old module (the line number of the CloudMessagingModul is incorrect) but I'll add a try/catch to the onTokenRefresh and update the version!

m1ga commented 6 years ago

https://github.com/hansemannn/titanium-firebase-cloud-messaging/pull/30