Skip to main content

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",
 

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?