Skip to main content
Question

[TypeError: Cannot read property 'setupPurchases' of null]

  • 23 August 2024
  • 1 reply
  • 166 views

Forum|alt.badge.img

I keep getting this error in my react native
Cannot read property 'setupPurchases' of nul

I am running react-native with expo bare workflow and running development build but i keep getting that error. This is my code below in App.tsx
 

  useEffect(() => {

    Purchases.setLogLevel(LOG_LEVEL.VERBOSE);

    let apiKey = "";

    if (isIOS) {

      apiKey = REVENUECAT_APPLE_API_KEY;

    } else if (isAndroid) {

      apiKey = REVENUECAT_ANDROID_API_KEY;

    }

    if (!apiKey) {

      console.error("RevenueCat API key is not set");

      return;

    }

    Purchases.configure({ apiKey:apiKey });

  }, []);

 

I am sure that the api key is being referenced properly and I have also tried upgrading and downgrading the versions of react-native-purchases but i still keep getting this error. Please let me know how to resolve this issue. I have also checked other forums for this issue but still couldn’t find a solution for this. I am currently using     "react-native-purchases": "^8.1.0",
 

This post has been closed for comments

1 reply

Ryan Glanz
RevenueCat Staff
Forum|alt.badge.img+8
  • RevenueCat Staff
  • 370 replies
  • August 27, 2024

Hi,

We do have a thread here and a detailed blog post here with some suggestions for setting up your build. If you follow these, is the error still persisting?


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings