Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: react-native-purchases & expo-dev-client issues #1583

Closed
1 task done
Klyado opened this issue Oct 4, 2023 · 3 comments
Closed
1 task done

[Bug]: react-native-purchases & expo-dev-client issues #1583

Klyado opened this issue Oct 4, 2023 · 3 comments

Comments

@Klyado
Copy link

Klyado commented Oct 4, 2023

What happened?

Hi there,

I recently tried to add onesignal sdk to my expo project and had some issues while doing it.
I've spent hours on it and finally found the reason so here are some information for you.

First I had this issue: Expected receiver of type com.amazon.device.iap.internal.d, but got kotlin.Unit

> 10-04 11:50:12.904 29357  4726 D OneSignal: [mqt_native_modules] Already instantiated: com.onesignal.location.internal.LocationManager@e2d9032
> 10-04 11:50:12.904 29357  4726 D OneSignal: [mqt_native_modules] initWithContext: using cached user df219000-d6bd-4c86-8b65-00cba2f5f312
> 10-04 11:50:12.905 29357  4726 D OneSignal: [mqt_native_modules] OperationRepo.enqueue(operation: {"name":"refresh-user","appId":"MY_APP_ID","onesignalId":"df219000-d6bd-4c86-8b65-00cba2f5f312"}, flush: false)
> 10-04 11:50:12.908 29357  4754 D OneSignal: [Thread-19] ConfigModelListener: fetching parameters for appId: MY_APP_ID
> 10-04 11:50:12.908 29357  4754 D OneSignal: [Thread-19] ParamsBackendService.fetchParams(appId: MY_APP_ID, subscriptionId: 43743f56-6aae-44bb-8c23-05b6f1e807c9)
> 10-04 11:50:12.909 29357  4755 D OneSignal: [OpRepo] RefreshUserOperationExecutor(operation: [{"name":"refresh-user","appId":"MY_APP_ID","onesignalId":"df219000-d6bd-4c86-8b65-00cba2f5f312","id":"945a9916-8bb9-4444-b1b6-7a82f364cf23"}])
> 10-04 11:50:12.910 29357  4726 E unknown:ReactNative: Exception in native call
> 10-04 11:50:12.910 29357  4726 E unknown:ReactNative: java.lang.IllegalArgumentException: Expected receiver of type com.amazon.device.iap.internal.d, but got kotlin.Unit
> 10-04 11:50:12.910 29357  4726 E unknown:ReactNative: 	at java.lang.reflect.Field.get(Native Method)
> 10-04 11:50:12.910 29357  4726 E unknown:ReactNative: 	at com.onesignal.core.internal.purchases.impl.TrackAmazonPurchase.start(TrackAmazonPurchase.kt:83)
> 10-04 11:50:12.910 29357  4726 E unknown:ReactNative: 	at com.onesignal.core.internal.startup.StartupService.start(StartupService.kt:16)
> 10-04 11:50:12.910 29357  4726 E unknown:ReactNative: 	at com.onesignal.internal.OneSignalImp.initWithContext(OneSignalImp.kt:247)
> 10-04 11:50:12.910 29357  4726 E unknown:ReactNative: 	at com.onesignal.OneSignal.initWithContext(OneSignal.kt:126)
> 10-04 11:50:12.910 29357  4726 E unknown:ReactNative: 	at com.onesignal.rnonesignalandroid.RNOneSignal.initialize(RNOneSignal.java:234)
> 10-04 11:50:12.910 29357  4726 E unknown:ReactNative: 	at java.lang.reflect.Method.invoke(Native Method)
> 10-04 11:50:12.910 29357  4726 E unknown:ReactNative: 	at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
> 10-04 11:50:12.910 29357  4726 E unknown:ReactNative: 	at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188)
> 10-04 11:50:12.910 29357  4726 E unknown:ReactNative: 	at com.facebook.jni.NativeRunnable.run(Native Method)
> 10-04 11:50:12.910 29357  4726 E unknown:ReactNative: 	at android.os.Handler.handleCallback(Handler.java:938)
> 10-04 11:50:12.910 29357  4726 E unknown:ReactNative: 	at android.os.Handler.dispatchMessage(Handler.java:99)
> 10-04 11:50:12.910 29357  4726 E unknown:ReactNative: 	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
> 10-04 11:50:12.910 29357  4726 E unknown:ReactNative: 	at android.os.Looper.loop(Looper.java:233)
> 10-04 11:50:12.910 29357  4726 E unknown:ReactNative: 	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
> 10-04 11:50:12.910 29357  4726 E unknown:ReactNative: 	at java.lang.Thread.run(Thread.java:923)
> 10-04 11:50:12.912 29357  4726 E unknown:ReactNative: Exception in native call
> 10-04 11:50:12.912 29357  4726 E unknown:ReactNative: java.lang.RuntimeException: Could not invoke OneSignal.addPermissionObserver
> 10-04 11:50:12.912 29357  4726 E unknown:ReactNative: 	at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:383)
> 10-04 11:50:12.912 29357  4726 E unknown:ReactNative: 	at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188)
> 10-04 11:50:12.912 29357  4726 E unknown:ReactNative: 	at com.facebook.jni.NativeRunnable.run(Native Method)
> 10-04 11:50:12.912 29357  4726 E unknown:ReactNative: 	at android.os.Handler.handleCallback(Handler.java:938)
> 10-04 11:50:12.912 29357  4726 E unknown:ReactNative: 	at android.os.Handler.dispatchMessage(Handler.java:99)
> 10-04 11:50:12.912 29357  4726 E unknown:ReactNative: 	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)

After tons of hours debugging this I found this was related to react-native-purchases package.

I also found you've got the same issue with flutter

While trying to fix it I installed expo-dev-client package and it went even worse with this issue:

> Your app just crashed. See the error below.
> java.lang.RuntimeException: Could not invoke OneSignal.hasNotificationPermission
>   com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:383)
>   com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188)
>   com.facebook.jni.NativeRunnable.run(Native Method)
>   android.os.Handler.handleCallback(Handler.java:938)
>   android.os.Handler.dispatchMessage(Handler.java:99)
>   com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
>   android.os.Looper.loop(Looper.java:233)
>   com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
>   java.lang.Thread.run(Thread.java:923)
> Caused by java.lang.reflect.InvocationTargetException
>   java.lang.reflect.Method.invoke(Native Method)
>   com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
>   com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188)
>   com.facebook.jni.NativeRunnable.run(Native Method)
>   android.os.Handler.handleCallback(Handler.java:938)
>   android.os.Handler.dispatchMessage(Handler.java:99)
>   com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
>   android.os.Looper.loop(Looper.java:233)
>   com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
>   java.lang.Thread.run(Thread.java:923)
> Caused by java.lang.Exception: Must call 'initWithContext' before use
>   com.onesignal.internal.OneSignalImp.getNotifications(OneSignalImp.kt:81)
>   com.onesignal.OneSignal.getNotifications(OneSignal.kt:62)
>   com.onesignal.rnonesignalandroid.RNOneSignal.hasNotificationPermission(RNOneSignal.java:437)
>   java.lang.reflect.Method.invoke(Native Method)
>   com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
>   com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:188)
>   com.facebook.jni.NativeRunnable.run(Native Method)
>   android.os.Handler.handleCallback(Handler.java:938)
>   android.os.Handler.dispatchMessage(Handler.java:99)
>   com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
>   android.os.Looper.loop(Looper.java:233)
>   com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
>   java.lang.Thread.run(Thread.java:923)

So I guess there is an issue with RevenueCat package. I think once it is fixed the second one with expo-dev-client will be too.

Let me know if you need more information.

Steps to reproduce?

1. Follow this tutorial to create an expo project : https://docs.expo.dev/tutorial/create-your-first-app/
2. Install this package : https://www.npmjs.com/package/react-native-purchases
3. Install this one : https://www.npmjs.com/package/expo-dev-client
4. Follow those steps : https://documentation.onesignal.com/docs/react-native-expo-sdk-setup
5. Prebuild
6. Run on Android

What did you expect to happen?

No issues while launching the app.

OneSignal Expo SDK version

react-native-onesignal: 5.0.1
onesignal-expo-plugin: 2.0.1

Platform

Android

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@rgomezp rgomezp transferred this issue from OneSignal/onesignal-expo-plugin Oct 4, 2023
@rgomezp
Copy link
Contributor

rgomezp commented Oct 4, 2023

Same issue as OneSignal/OneSignal-Flutter-SDK#709

@vegaro
Copy link

vegaro commented Oct 5, 2023

I work at react-native-purchases. I've been looking into this, and I believe the issue is in this line https://github.com/OneSignal/OneSignal-Android-SDK/blob/5.0.2/OneSignalSDK/onesignal/core/src/main/java/com/onesignal/core/internal/purchases/impl/TrackAmazonPurchase.kt#L77.

Method e changed in version 3.0.4 of the Amazon SDK (see https://www.diffchecker.com/mAggUTRG/ )

In 3.0.4

public boolean e() {
        this.h();
        return com.amazon.a.a.a((Application)this.e.getApplicationContext());
}

In 3.0.1, 3.0.2, 3.0.3

public static d e() {
        return c;
 }

react-native-purchases depends on version 3.0.3 of the Amazon Appstore SDK, and it looks like OneSignal-Android compiles against the latest available (3.0.4), so maybe that's where the issue is? That the function is not the same as the one in runtime?

@nan-li
Copy link
Contributor

nan-li commented Oct 7, 2023

Hi @Klyado,

Thanks for reporting, we had a bug and just released a new version of react-native-onesignal with the fix for the crash Expected receiver of type com.amazon.device.iap.internal.d, but got kotlin.Unit.

Please see release 5.0.2.

Let us know if you have any remaining issues!

@nan-li nan-li closed this as completed Oct 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants