2

I'm getting familiar with React Native and I've had an app working on simulator and device.

On both cases the node.js server is running on my local machine, and it is required in order for the app to run. I understand that for a release version of the app I would have to have a stable and reliable node server running somewhere (AWS), and have my app point at that.

However, can the app be bundled, somehow, with a node server? This way the app can run offline at any time.

This is probably harder on iOS than it'll be on Android, but I wanted to know what your thoughts were on this.

Thanks!

2 Answers 2

1

It is possible with jxcore. Check out this sample. https://github.com/agenthunt/EmbeddedJXcoreEngineIOS/tree/master/Examples/ReactNativeJXcoreTodoApp

Sign up to request clarification or add additional context in comments.

Comments

1

iOS

As of today,

react-native-cli: 2.0.1
react-native: 0.47.2

you can just select the Release scheme in Xcode, a script from a build phase ../node_modules/react-native/scripts/react-native-xcode.sh will launch and bundle the JS package into the app.

Then you just change the jsCodeLocation in AppDelegate.m to point to the bundle:

jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];

Android

Just download the bundle into assets directory of your app. Make sure the assets folder exists.

curl "http://localhost:8081/index.android.bundle?platform=android" -o "android/app/src/main/assets/index.android.bundle"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.