question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using hooks, getting Not initialized, Please call initConnection()

See original GitHub issue

Please use Discussion board if you want get some help out of it. Please report issue if there is a bug.

Version of react-native-iap

7.5.0

Version of react-native

0.63.4

Platforms you faced the error (IOS or Android or both?)

Android only

Expected behavior

I should not have to call initConnection using hooks

Actual behavior

After connected is true we getSubscriptions(ids) but it throws an error Not initialized, Please call initConnection()

Tested environment (Emulator? Real Device?)

Real device

Steps to reproduce the behavior

App.js is wrapped and exported as withIAPContext(App)

The code:

export const useSubscription = () => {
  // initConnection();  // <-- In dev, this will avoid the error. Not in production.
  const {
    connected,
    subscriptions,
    finishTransaction,
    getSubscriptions,
    currentPurchase,
    currentPurchaseError,
  } = useIAP();
  
  ...
  
  useEffect(() => {
    if (connected) {
      getSubscriptions(subscriptionIds).catch((err) => { // <-- Error here
        Sentry.Native.captureException(err)
      });
    }
  }, [connected]);

 ...

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:18

github_iconTop GitHub Comments

3reactions
okcompewtercommented, Apr 27, 2022

Still an ongoing issue for me, any help?

2reactions
danicunhaccommented, Sep 30, 2022

@andresesfm I found another issue and saw that I wasn’t connected to the play store.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the react-native-iap.initConnection function in ...
To help you get started, we've selected a few react-native-iap.initConnection examples, based on popular ways it is used in public projects.
Read more >
RenOkimoto@ベリロン on Twitter: "hooks 使ってたら ...
Using hooks, getting Not initialized, Please call initConnection() · Issue #1526 · dooboolab/reac... Please use Discussion board if you want ...
Read more >
Announcing React Native IAP hooks | by Hyo - Medium
With useIAP hook, these are handled automatically. You do not have to call initConnection imperatively and calling useIAP() is enough for ...
Read more >
React Native IAP - Javatpoint
To initialize a native module, you can call initConnection() at the beginning of your application's lifecycle. It must be done on a top-level...
Read more >
react-native-iap just hangs on ios trying to get subscriptions on ...
There don't appear to be any other issues regarding this phone's ability to make purchases. Logs. LOG [Subscription] Will init connection LOG [ ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found