[Bug]: Could not invoke OneSignal.addNotificationClickListener
leminhcse opened this issue · 2 comments
leminhcse commented
What happened?
Sometimes, I got some crashes from firebase crashlytics:
Exception java.lang.RuntimeException: Could not invoke OneSignal.addNotificationClickListener
at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:383)
at com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java:188)
Steps to reproduce?
I could not reproduce this so I'm not sure this happen when user launch app or while using app.
Within 24 hours, there are about 50 events logged from crashlytics.
What did you expect to happen?
App can not crash
React Native OneSignal SDK version
5.0.6
Which platform(s) are affected?
- iOS
- Android
Relevant log output
Exception java.lang.RuntimeException: Could not invoke OneSignal.addNotificationClickListener
at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:383)
at com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java:188)
at com.facebook.jni.NativeRunnable.run
at android.os.Handler.handleCallback (Handler.java:938)
at android.os.Handler.dispatchMessage (Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java:27)
at android.os.Looper.loop (Looper.java:223)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java:228)
at java.lang.Thread.run (Thread.java:923)
Caused by java.lang.reflect.InvocationTargetException:
at java.lang.reflect.Method.invoke
at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java:372)
Caused by java.lang.Exception: Must call 'initWithContext' before use
at com.onesignal.internal.OneSignalImp.getNotifications (OneSignalImp.kt:96)
at com.onesignal.OneSignal.getNotifications (OneSignal.kt:62)
at com.onesignal.rnonesignalandroid.RNOneSignal.addNotificationClickListener (RNOneSignal.java:344)
Code of Conduct
- I agree to follow this project's Code of Conduct
jennantilla commented
Hello @leminhcse apologies for the delay in getting back to you. Can you please update to our latest SDK version and let us know if you are still having issues?
Thanks!
alfonsosn commented
I was having the same issue, but it seemed that I had a hook that was calling: OneSignal.Notifications.addEventListener('click',
before I called OneSignal.initialize(Config.ONE_SIGNAL_APP_ID);
As a quick fix, I moved initialize
as the first line of my app's RootComponent and the problem went away.