Cannot Import In App Purchases - Native Module Cannot Be Null

SDK Version: 45.0.0
Platform: IOS

Hi Everyone,
Is there anyone who recently integrated In App Purchases? We are trying to import this library to our project and nothing seems to be working. It is not even working with a bare boilerplate project. There might be a compatibility issue, is there any workaround for this? Our app is rejected due to payment and we really need to add IAP. We have been trying to make IAP API work for days now and nothing seems to be working.

To recreate the issue, do a simple bare workflow setup:

expo init --template bare-minimum 
expo install expo-in-app-purchases
npm install expo-in-app-purchases
npx pod-install

Import the library to App.js and run expo start

import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import * as InAppPurchases from 'expo-in-app-purchases';
export default function App() {
  return (
    <View style={styles.container}>
      <Text>Open up App.js to start working on your app!</Text>
      <StatusBar style="auto" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

Snack link is here.
Here is the issue: In App Purchase - Native Module Cannot Be Null Error · Issue #17581 · expo/expo · GitHub

Does anyone know how to fix this_

Hi @eddyildiz

What are you running the app/snack in? Expo Go?

I don’t think it will work in Expo Go. You could try building a dev client and using that instead of Expo Go. I’ve never tried using a dev client to run a Snack, so not sure if that actually works, but now that I think about it, I suppose it should be able to work.

2 Likes

Since you’re installing a native module, you’ll need to build the app somehow. You could either do that with Xcode on your own computer or with EAS in the cloud as @wodin mentions.

The Expo Go client doesn’t have the binary code in it needed for IAPs and so that’s why the docs say you need to use the bare workflow and why you need to build this yourself.

1 Like

Here’s a video that might be helpful. Implementing In-App Purchases in Expo & React Native - YouTube

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.