react-native-purchases
react-native-purchases copied to clipboard
[Expo go] Invariant Violation: `new NativeEventEmitter()` requires a non-null argument.
- [X ] I have updated Purchases SDK to the latest version
- [ X] I have read the Contribution Guidelines
- [X ] I have searched the Community
- [ X] I have read docs.revenuecat.com
- [ X] I have searched for existing Github issues
- Environment
- Platform: IOS
- SDK version: EXPO 45
- React Native version: 0.68.2
Describe the bug hello, I wanted to use RevenueCat to simplify payments, but I am blocked under ios with error, I am under Expo 45 does anyone have a solution?
Invariant Violation: new NativeEventEmitter() requires a non-null argument.
const initPaymments = async () => {
Purchases.setDebugLogsEnabled(true);
if (Platform.OS === "ios") {
await Purchases.setup(REVENUECAT_SDK_KEY_IOS);
} else if (Platform.OS === "android") {
await Purchases.setup(REVENUECAT_SDK_KEY_ANDROID);
}
};
Hey @alexandrebouttier, did you make sure to run pod install in your app's iOS folder? It sounds like that could be the issue.
Our full ReactNative installation docs are here, in case those help too.
Let me know if you're still seeing the issue!
Hey @alexandrebouttier, did you make sure to run
pod installin your app's iOS folder? It sounds like that could be the issue.Our full ReactNative installation docs are here, in case those help too.
Let me know if you're still seeing the issue! hello, thank you for your answer I do not want to eject expo for my application , does revenueCat work without ejecting expo?
hey @alexandrebouttier it does work, check out this blog post for more info: https://www.revenuecat.com/blog/in-app-puchase-expo-managed-workflow/
hey @alexandrebouttier it does work, check out this blog post for more info: https://www.revenuecat.com/blog/in-app-puchase-expo-managed-workflow/
my problem probably comes from my cpu I have an M1 Max chip
Hey @alexandrebouttier 👋
Are you able to explain a little more about what issues are happening with the M1? I was able to create an Expo Managed app for both iOS and Android on my M1 🤔 Curious what issues you might be facing and how we can help!
Hey @alexandrebouttier 👋
Are you able to explain a little more about what issues are happening with the M1? I was able to create an Expo Managed app for both iOS and Android on my M1 🤔 Curious what issues you might be facing and how we can help!
hello, how did you install it? , did you have to do this? arch -x86_64 /bin/bash -c "pod install"
@alexandrebouttier I sometimes do use arch -x86_64 but I don't think I've had to recently 🤔 Are you seeing this error when running expo install react-native-purchases or a different command?
Are you able to post your entire console output where you are seeing errors?
Hey, I am observing the same error in my managed expo workflow. It happens when calling Purchases.setupor Purchases.configure methods. Just to note, I am trying to start application using the expo start and using Expo Go.
All I am doing is installing react-native-purchaseswith expo install react-native-purchases and calling the above configuration method.
Environment
- Platform: IOS
- SDK version: I tried different versions of
react-native-purchasesfrom latest 5.0.0 beta 1 to 4.5.2, got the exact same error. - React Native version: 0.68.2
- Expo version: 45.0.0
It looks like you might need to do a clean- somebody else reported this issue as well and that seemed to fix it https://github.com/RevenueCat/react-native-purchases/issues/386#issuecomment-1200064533
Encountering the same issue. I've tried cleaning the cache and rebuilding the dev client to no avail.
@taquitos Cleaning, rebuilding etc doesn't solve the issue. I am afraid Expo Go is not supported because building locally and running in my device with expo run:ios --device "UUID" seems to be solving the problem (or expo start --dev-client after installing to device).
Ok, that's a bummer. I know this doesn't help you at the moment, but I'm going to chat with the team and see what we can do. We'll get back to ya.
I don't know if this will help, but I setup a new project, following our blog post: https://www.revenuecat.com/blog/in-app-puchase-expo-managed-workflow/ and it seems to work for me. It's using the following packages:
"packages": {
"": {
"name": "my-app",
"version": "1.0.0",
"dependencies": {
"expo": "~45.0.0",
"expo-dev-client": "~1.0.1",
"expo-status-bar": "~1.3.0",
"react": "17.0.2",
"react-devtools": "^4.25.0",
"react-dom": "17.0.2",
"react-native": "0.68.2",
"react-native-purchases": "^5.0.0-beta.1",
"react-native-web": "0.17.7"
},
Note: 5.0.0-beta.2 is about to be released
My greatly simplified App.tsx:
import React, { useEffect, useState } from 'react';
import { Platform, Text, View } from 'react-native';
import Purchases, { PurchasesOffering } from 'react-native-purchases';
const APIKeys = {
apple: "your_revenuecat_apple_api_key",
};
export default function App() {
const [currentOffering, setCurrentOffering] = useState<PurchasesOffering | null>(null);
useEffect(() => {
const fetchData = async () => {
const offerings = await Purchases.getOfferings();
setCurrentOffering(offerings.current);
};
Purchases.setDebugLogsEnabled(true);
Purchases.configure(APIKeys.apple);
fetchData()
.catch(console.log);
}, []);
return (
<View>
<Text>Current Offering: {currentOffering.identifier}</Text>
</View>
);
}
This may or may not point you in a direction that helps, but I wanted to mention it in the meantime. Unfortunately, none of us are ReactNative or Expo experts. It's really strange that you're seeing this since it looks like we fixed the issue in https://community.revenuecat.com/product-updates/react-native-4-5-3-1407
One other thing you can try doing is bringing this up in our community. Other folks might be able to help troubleshoot this as well.
Thanks a lot for deep diving into this, really appreciated.
Just to clarify some point though, the blog post you mentioned also using expo start --dev-client to start the application (I think you also started in this way), which is also working in my setup. The problem is in my case using Expo Go and running the application in there, which throws this error.
Actually, it would not be possible to test anything for in-app purchases in Expo Go because that is a separate application and we won't be able to add products to corresponding Apple account or use sandbox. But it would be nice to not get an error as it is really useful for testing other parts of the business logic (considering just calling configure throws this error).
Anyway, I think I am fine as this is not blocking me and only causing small inconvenience during development.
Ahhh, thank you for the clarification.
This issue has been automatically marked as stale due to inactivity. It will be closed if no further activity occurs. Please reach out if you have additional information to help us investigate further!
I have the same issue using expo managed workflow
also using the expo go app :)
Migrated to our backlog as CSDK-396
I'm running into the same issue but I'm in the Bare Workflow (React Native with Expo modules). Strangely I only get this error on a real iPhone, the simulator doesn't throw this error.
import Purchases from "react-native-purchases";
// Invariant Violation: `new NativeEventEmitter()` requires a non-null argument.
Any ideas?
EDIT: I was able to solve this error by rebuilding and reinstalling the app back onto the iPhone with XCode, after a fresh npx pod-install.
Hi guys, I'm not sure if it's that helpful to you but this is the error that shows up on my screen.
This is an expo-dev-client SDK46 managed-workflow. Version of RNP is 5.0.0-beta.6.

Hi, I am getting the same issue with the "TypeError: null is not an object (evaluating 'RNPurchases.isConfigured')" error in release APK. I am working on the expo app. "expo": "^45.0.0" "react-native-purchases": "^5.0.0-beta.6" // also tried "react-native-purchases": "4.6.1"
have used the below code to initialize react-native-purchases Purchases.configure({ apiKey: "goog_xxxxxxxxxxxxxxxxxxxxxxxxxxx", appUserID: null, observerMode: false }); or Purchases.setup("goog_xxxxxxxxxxxxxxxxxxxxxxxxxxx"); // with version 4.6.1
I followed the steps in https://www.revenuecat.com/blog/in-app-puchase-expo-managed-workflow/ to make it work in profile development, but the release APK I generate for uploading to the play store is giving me an error. Are we supposed to do any additional steps?
hey @alexandrebouttier it does work, check out this blog post for more info: https://www.revenuecat.com/blog/in-app-puchase-expo-managed-workflow/
Thank you very much it worked for me, no need to do a pod install, I deleted my node modules and my yarn lock and followed the instructions and it worked
Alright guys, just installed the new 5.0.0 release and I can happily say it's working. I am so relieved!
@vbylen thanks for reporting back! I'm glad it's working now. Have a great day!
I'm tentatively closing this out for now, but feel free to reopen if this comes up again after updating to 5.0.0!
Hi All,
I'm getting the same error with managed Expo project.
"expo": "^45.0.0",
"react-native": "0.68.2",
"react-native-purchases": "^5.0.2",
Do you have any idea?
Thank you
@kozarip for Expo, you will have to make Development builds in order for the SDK to work.
This is documented here: https://www.revenuecat.com/docs/reactnative#option-2-using-expo
The easiest way to get it done is by doing a development build running one of the following:
npx expo run:android -d
npx expo run:ios -d
@aboedo It's working. Thank you
@kozarip thanks for reporting back!! I'm glad it's working 🙌