Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React native android deploy files to server

I am new to React Native I want to know how is it possible to deploy react native part or code like javascript files and assets on server and then use it.

Currently it is showing as localhost

Please let me know how to deploy it on server also is it possible or not.

Do I need to update app on play store every time when I change something in react part of my code?

what exactly code push does and is there any way by which I can load my react native bundle from server and update app dynamically

like image 499
amodkanthe Avatar asked May 30 '18 07:05

amodkanthe


2 Answers

React-native compiles down to the two native languages. Effectively you have 2 applications, non of them web.

You could have an image assets remote on a server and use the URL in the react-native code combined with a cache (so you don't have to download the asset every time).

Considering JavaScript files, I would say no. Unless you create an server and request the functionality by API calls.

And no, you don't have to interact with the play store every time, but usually you do :)

like image 189
Jakob Göran Thomasson Avatar answered Oct 22 '22 03:10

Jakob Göran Thomasson


I think you need to understand how React Native works in order to understand.

What RN actually does is to expose native API to your Javascript code base. Basically a RN App is composed by 2 things:

enter image description here

As you can immagine the Native part is everything that is written in Swift/ Objective-C/ Java and that is the part you can not update without going through the App stores.

Now the interesting thing is the JS part, remember we said that basically you are consuming native API with JS. If you notice when you run react-native run-ios or react-native run-android a server is instanced which serves a bundle to your emulator / physical device.

Now if you think about it basically when you open the App the bundle is downloaded an then run. When you update your codebase while the app is running on the emulator the servers sends a signal trough the socket to notify the client that an update is available. At that point the client downloads the bundle and the app is reloaded.

Now to answer your question, yes you can serve the JS Bundle on your server and make the app check when is loaded or resumed if a new version of the JS Bundle is available, if so to download it (OTA update). As you can understand only the Javascript part can be update in this way and not the native part as well.

Then again, there are a few services that already do this like codepush by MS.

like image 23
Sid Avatar answered Oct 22 '22 02:10

Sid