You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Android app crashes as soon as I try to add a tag to the user
Steps to reproduce?
1. install the latest version `"react-native-onesignal": "^5.1.2"`2. initialize the app using:
OneSignal.initialize(ONESIGNAL_APP_ID);
OneSignal.Debug.setLogLevel(LogLevel.Verbose);
3. right after it, call `OneSignal.User.addTag('testKey', 'testValue');`4. build the app either on a simulator or an actual device
What did you expect to happen?
I expected the OneSignal user to get created and the tag to get assigned to that user.
What actually happened on Android, the app crashes sometimes. The native log of the crash can be seen below
React Native OneSignal SDK version
5.1.2
Which platform(s) are affected?
iOS
Android
Relevant log output
Exception in native call
java.lang.RuntimeException: Could not invoke OneSignal.addTag
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:381)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:149)
at com.facebook.jni.NativeRunnable.run(Native Method)
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:29)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:234)
at java.lang.Thread.run(Thread.java:920)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:149)
at com.facebook.jni.NativeRunnable.run(Native Method)
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:29)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:234)
at java.lang.Thread.run(Thread.java:920)
Caused by: java.lang.Exception: Must call 'initWithContext' before use
at com.onesignal.internal.OneSignalImp.getUser(OneSignalImp.kt:116)
at com.onesignal.OneSignal.getUser(OneSignal.kt:46)
at com.onesignal.rnonesignalandroid.RNOneSignal.addTag(RNOneSignal.java:597)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:149)
at com.facebook.jni.NativeRunnable.run(Native Method)
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:29)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:234)
at java.lang.Thread.run(Thread.java:920)
### Code of Conduct
- [X] I agree to follow this project's Code of Conduct
<!-- probot = {"onesignal-probot":{"response_time_in_business_days":2}} -->
The text was updated successfully, but these errors were encountered:
@1awaleed thanks for reaching out! From the stack trace it looks like addTag is being called before OneSignal fully initializes. Would you be able to share the full log from the device so we can see why initialization hasn't completed?
@jennantilla Thanks for addressing my issue.
I have to try to reproduce it again, it happens once every 10 tries but in the mean time, I would really look forward to have the option to await the async initialization. Or is there a reason why it is not an option?
What happened?
Android app crashes as soon as I try to add a tag to the user
Steps to reproduce?
What did you expect to happen?
I expected the OneSignal user to get created and the tag to get assigned to that user.
What actually happened on Android, the app crashes sometimes. The native log of the crash can be seen below
React Native OneSignal SDK version
5.1.2
Which platform(s) are affected?
Relevant log output
The text was updated successfully, but these errors were encountered: