Skip to main content

Apologies for a basic question. This is my first RevenueCat project…

I’m running an Expo managed project for React Native. react-native-purchases is installed and imported. I can call setDebugLogsEnabled successfully. But I cannot see a “setup” method on the Purchases object? If I type the code to run setup() I get the following error:


What am I missing?

Thx!

I realize the code is missing the api-key. The issue is more fundamental. The setup function is missing. I can see the rest of the API.


I’m running into the exact same issue. My project uses React Native with Expo Modules (Bare Workflow). I’ve cleaned the cache, reinstalled node_modules, reinstalled pods - nothing works.

import Purchases from "react-native-purchases";
// ...
// ...

if (Platform.OS === "ios") {
Purchases.setup("ios_api_key");
}

Gives me the error: 

TypeError: _reactNativePurchases.default.setup is not a function

 


I took a look at the RevCat source code. I could not see a setup function in there. In the interest of time, I switched to using the Glassfy module instead. That is going quite smoothly.


Hey, guys I am having the exact same issue in expo manged workflow. Any progress towards a solution?


Same problem here also. I created a development IOS build as mentioned in the documentation and launched it using expo start --dev-client in an iPhone but the same error was surfaced. In the article and documentation it was mentioned that everything is supported in Expo Managed workflow but it seems it’s not. Please look into this matter urgently. I am running on latest Expo SDK 46.


I took a look at the RevCat source code. I could not see a setup function in there. In the interest of time, I switched to using the Glassfy module instead. That is going quite smoothly.

I tried Glassfy module. But while fetching with sku ID I am getting an error saying: “Product not retrieved from SKProduct”. Do you have any idea what does that mean?


I checked the source code and type declaration files many times and it looks like there is no `setup` function on the `Purchase` object.

Only a `config` property, but when I use that 

Purchases.configure({ apiKey: API_KEY});

it says 

There is an issue with your configuration. Check the underlying error for more details.

 


Hello! 👋 

I commented on a similar GitHub issue to this and `Purchases.setup` is in v4 of our React Native SDK and it got renamed to `Purchases.configure` in v5. v5 is currently in beta and it looks like that is what is being used here! `5.0.0-beta.4` is the latest beta.

This should be getting released soon and all of the docs, blogs, and examples will be updated for that when it’s released. However, you can switch to v4 and the docs and blogs should lead you down a correct path!

Hope this helps but let me know if not!


To save you a search, Josh is referring to this thread: https://github.com/RevenueCat/react-native-purchases/issues/406

If you’re running 5.0.0-beta.5 (the latest) ignore the current docs and use the following.

await Purchases.configure({ apiKey: KEYS.PUBLIC_IOS_SDK_KEY });

Double check your package-lock.json to see you’re definitely on 5. In my case, the package.json has "react-native-purchases": "^5.0.0-beta.4" but node grabs 5.

 

Sorry but I’ve become a bit skeptical of this service based on this miscommunication. I’m still getting an error from just importing on my real device (simulator is okay) - which leads me think something else is up. Is this related?

import Purchases from "react-native-purchases";

// Invariant Violation: `new NativeEventEmitter()` requires a non-null argument.

 


Update: I was able to solve the “Invariant Violation” error by rebuilding and reinstalling the app in XCode after a fresh npx pod-install.

The docs really need updating asap, I’m finding so many confusing and conflicting instructions. For instance the Quickstart section’s “10. Get Subscription Status” languages have differing method names, and don’t match up with what is on the dedicated “Checking Subscription Status” page. getPurchaserInfo doesn’t exist but it’s mentioned in the examples despite getCustomerInfo being in the instructions.


@Mitch The React Native docs reflect what is live in version `4.x.x` where it still is `getPurchaserInfo`. Once `5.0.0` is officially release (its still in beta 5), the docs will all be updated to reflect that!

But glad to hear you got it solved after a fresh `npx pod-install`. Are you using a managed Expo app or ejected?

Thanks!


Thanks Josh, understood. I’m using the Bare Workflow (React Native with Expo modules installed on top).


I switched to Glassfy and am live. Great support and ½ the price.


i’d recommend signing up for the updates from the revenueCat team as they update packages.  saw the 5.0.1 update for react native this morning and sure enough, the bug fix i wanted was in there.  understandable that the tutorial lags sometimes but team seems to be working hard taking the product out of its infancy to something truly useful across many platforms.


I checked versions in NPM and setup function is located in version 4.6.2. The newer versions of react-native-packages uses configure(). Hope this helps.


building a new development build and installing and using that worked for me


Reply