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

[Android] Unable to auto-initialise connection #2836

Closed
Aximem opened this issue Aug 30, 2024 · 3 comments · Fixed by #2839
Closed

[Android] Unable to auto-initialise connection #2836

Aximem opened this issue Aug 30, 2024 · 3 comments · Fixed by #2839
Labels
🤖 android Related to android 🙏 help wanted Extra attention is needed

Comments

@Aximem
Copy link

Aximem commented Aug 30, 2024

Description

I know an issue have already been opened and closed for this issue but it seems the lastest versions of the lib have increased the occurence of it. From rare to often

We upgraded the lib version from 12.10.7 to 12.15.2, without changing our code and this issue is happening from 1 time in a week, to 100 times in a week.

Environment:

  • react-native-iap: 12.15.2
  • react-native: 0.73.1
  • Platforms (iOS, Android, emulator, simulator, device): Android

To Reproduce

useEffect(() => {
    if (connected) { // connected is coming from useIAP hook
      (async () => {
        try {
          if (IS_ANDROID) {
            await flushFailedPurchasesCachedAsPendingAndroid();
          } else {
            await clearTransactionIOS();
          }
          setClearedPendingPurchases(true);
          await getSubscriptions({skus: Object.values(premiumItemSub)});
        } catch (error: any) {
          // Throw Unable to auto-initialise connection
        }
      })();
    }
  }, [connected]);

[Optional] Additional Context

It seems that users can still be able to get subscriptions after some tries or later.

@ramakula
Copy link
Contributor

ramakula commented Sep 4, 2024

#2839

I added errorCallback where this can be retried.

@hyochan hyochan added 🤖 android Related to android 🙏 help wanted Extra attention is needed labels Sep 7, 2024
hyochan added a commit that referenced this issue Sep 7, 2024
Catch 'unable to auto initialize connection', add optional error
callback.

This has been discussed here:
#2836
and here:
#2265

Closes #2836

---------

Co-authored-by: Rammohan Akula <rammohan.akula@quicken.com>
Co-authored-by: hyochan <dooboolab@gmail.com>
@Aximem
Copy link
Author

Aximem commented Sep 9, 2024

Thanks for the update but I don't how this is helping for this issue.
It has been introduced in the latest versions and user who encountered this issue still have the issue after multiple tries, killing app etc. Getting a callback to retry will end to the same error, again and again.

@Aximem
Copy link
Author

Aximem commented Sep 17, 2024

We decided to patch the lib and rollback the changes that have been applied here on eventEmitter.ts : bdfd9f4

It seems that this fix generated more issues than it resolved.

index 5aaf51b..f5ae652 100644
--- a/node_modules/react-native-iap/src/eventEmitter.ts
+++ b/node_modules/react-native-iap/src/eventEmitter.ts
@@ -59,17 +59,17 @@ export const purchaseUpdatedListener = (
     proxyListener,
   );
 
-  if (isAndroid) {
-    getAndroidModule()
-      .startListening()
-      .catch((error: unknown) => {
-        if (errorCallback) {
-          errorCallback(error);
-        } else {
-          throw error;
-        }
-      });
-  }
+  // if (isAndroid) {
+  //   getAndroidModule()
+  //     .startListening()
+  //     .catch((error: unknown) => {
+  //       if (errorCallback) {
+  //         errorCallback(error);
+  //       } else {
+  //         throw error;
+  //       }
+  //     });
+  // }
 
   return emitterSubscription;
 };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 android Related to android 🙏 help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants