Search code examples
react-nativein-app-purchaseexpoin-app-billingin-app-subscription

React Native: Is it possible to use Expo just for development?


I am new to Expo but so far it seems super neat not having to open up Android Studio / Xcode to run my app locally. Not having to touch that stuff makes it so much more convenient to develop.

However, I want to incorporate in app purchases (subscriptions) in my app and from the research I've done so far it doesn't seem like Expo's solution (https://docs.expo.io/versions/latest/sdk/in-app-purchases/) is very developed.

I found this npm package for in app purchases and it looks promising: https://github.com/dooboolab/react-native-iap. However it is not supported by Expo, and I don't feel like it's worth giving up all the benefits of Expo just for this one feature.

I noticed a comment in the issues here that was quite intriguing: https://github.com/dooboolab/react-native-iap/issues/174#issuecomment-393704277

This person suggests that I can continue using the master branch with Expo, and then following these steps to eject and deploy when time is ready. I've never done this, but I'm wondering if this could work:

On master:

1) Run npm install --save react-native-iap but DON'T run react-native link react-native-iap.

2) Wrap my In App Purchase module with this code. This way your code won't crash when calling IAP methods

import { NativeModules } from 'react-native';
const { RNIapModule } = NativeModules;
function hasIAP() {
  return !!NativeModules.RNIapModule;
}

3) Continue developing using Expo, and just skipping the IAP stuff if !hasIAP()

On separate branch used for final QA / deployment:

1) Create a new branch called detached

2) Run expo eject

3) Run react-native link react-native-iap and all the other Manual Installation steps listed here: https://github.com/dooboolab/react-native-iap#manual-installation

4) QA everything

5) Deploy

Does anyone have experience doing this hybrid "expo for development, no expo for production" approach?


Solution

  • If you eject and use the Expo, you can use it like a default React-native project. The Android folder and the iOS folder are created and you will enter the appropriate package name before you create them. The modules you have installed and the modules in Expo are added to the package list when you eject the Expo. Check MainApplication.java for Android or Info.list files for iOS. There are some things that do not apply to App.json settings that were responsible for setting up after you ejected the Expo. It can be set up by referring to the official document.

    Once the Expo has been ejected, the React-native link command is performed brilliantly.

    ejecting the Expo does not change or disappear from the module usage