react-native-purchases icon indicating copy to clipboard operation
react-native-purchases copied to clipboard

[Expo go] Invariant Violation: `new NativeEventEmitter()` requires a non-null argument.

Open alexandrebouttier opened this issue 3 years ago • 19 comments

  1. Environment
    1. Platform: IOS
    2. SDK version: EXPO 45
    3. 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);
    }
  };

alexandrebouttier avatar Jul 25 '22 19:07 alexandrebouttier

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!

beylmk avatar Jul 25 '22 23:07 beylmk

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! hello, thank you for your answer I do not want to eject expo for my application , does revenueCat work without ejecting expo?

alexandrebouttier avatar Jul 26 '22 07:07 alexandrebouttier

hey @alexandrebouttier it does work, check out this blog post for more info: https://www.revenuecat.com/blog/in-app-puchase-expo-managed-workflow/

beylmk avatar Jul 26 '22 16:07 beylmk

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

alexandrebouttier avatar Jul 26 '22 17:07 alexandrebouttier

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!

joshdholtz avatar Jul 27 '22 14:07 joshdholtz

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 avatar Jul 28 '22 07:07 alexandrebouttier

@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?

joshdholtz avatar Jul 29 '22 20:07 joshdholtz

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-purchases from 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

ahaltindis avatar Jul 30 '22 18:07 ahaltindis

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

taquitos avatar Aug 01 '22 19:08 taquitos

Encountering the same issue. I've tried cleaning the cache and rebuilding the dev client to no avail.

cloudorbush avatar Aug 01 '22 22:08 cloudorbush

@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).

ahaltindis avatar Aug 02 '22 16:08 ahaltindis

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.

taquitos avatar Aug 02 '22 17:08 taquitos

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.

taquitos avatar Aug 03 '22 17:08 taquitos

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.

ahaltindis avatar Aug 03 '22 20:08 ahaltindis

Ahhh, thank you for the clarification.

taquitos avatar Aug 03 '22 23:08 taquitos

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!

stale[bot] avatar Aug 11 '22 01:08 stale[bot]

I have the same issue using expo managed workflow

also using the expo go app :)

jonasgroendahl avatar Aug 11 '22 06:08 jonasgroendahl

Migrated to our backlog as CSDK-396

taquitos avatar Aug 12 '22 20:08 taquitos

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.

liquidvisual avatar Aug 16 '22 02:08 liquidvisual

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.

image

cloudorbush avatar Aug 19 '22 02:08 cloudorbush

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?

imchintan avatar Aug 19 '22 11:08 imchintan

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

alexandrebouttier avatar Aug 22 '22 20:08 alexandrebouttier

Alright guys, just installed the new 5.0.0 release and I can happily say it's working. I am so relieved!

cloudorbush avatar Aug 23 '22 06:08 cloudorbush

@vbylen thanks for reporting back! I'm glad it's working now. Have a great day!

aboedo avatar Aug 23 '22 15:08 aboedo

I'm tentatively closing this out for now, but feel free to reopen if this comes up again after updating to 5.0.0!

aboedo avatar Aug 23 '22 15:08 aboedo

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 avatar Sep 23 '22 12:09 kozarip

@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 avatar Sep 23 '22 14:09 aboedo

@aboedo It's working. Thank you

kozarip avatar Sep 27 '22 12:09 kozarip

@kozarip thanks for reporting back!! I'm glad it's working 🙌

aboedo avatar Sep 27 '22 12:09 aboedo