0

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?

bigpotato
  • 26,262
  • 56
  • 178
  • 334
  • Are you saying that you are using the module without disconnecting the Expo? – hong developer Aug 06 '19 at 02:59
  • @hongdevelop I want to continue coding using Expo as if the module is there, and only right before I deploy will I eject Expo and install / QA the IAP stuff. My question is whether this theory would work. Like what would happen to all my other Expo dependencies that depend on Expo's managed workflow? Would they just magically install properly after ejecting? – bigpotato Aug 06 '19 at 03:02
  • 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. – hong developer Aug 06 '19 at 03:09
  • Once the Expo has been ejected, the `React-native link` command is performed brilliantly. – hong developer Aug 06 '19 at 03:10
  • In fact, I also made a project through Expo, ejected the Expo and used the module you were asking questions about. – hong developer Aug 06 '19 at 03:15
  • @hongdevelop Oh wow! So for example, if I use Expo's Permissions (installed through: `expo install expo-permissions`), and then run `expo eject`, the permissions code will still work? but I'm importing it with `import * as Permissions from "expo-permissions";` though? I thought ejecting Expo would make everything expo related break? – bigpotato Aug 06 '19 at 03:21
  • Yes, ejecting the Expo does not change or disappear from the module usage. – hong developer Aug 06 '19 at 04:25

1 Answers1

1

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

hong developer
  • 13,291
  • 4
  • 38
  • 68