react-native-community/discussions-and-proposals

app server update for private production - React Native

Productivix opened this issue · 9 comments

Introduction

I am an Android RN app developper for non-public customers.
I used before a proprietary android dev tool (I do not want to give its name) and I appreciated a function that I would appreciate also on RN.
May be we can do it ?

I describe here what I had :
When I produced an app and released it to my customer I put in the code a test at start of the app to look for releases on my serveur. If one release of a increased version of the same app name was available, the small file I had prepared before (named upgrade) what downloaded inside the app and the app restarted in the new release version. I never used Google store. I had a proprietary API on my server that was handling the exchange.
This is in our "word" similar to METRO when we develop with RN.

Details

I would want to discuss about how and what to develop or use that exist to put inside the app and inside an API to do that feature described
The limit is : once we have build with a stack (yarn add made and build made) it is only app code on that stack that can be modified with that tool, in fact similar with the dev process but in production with a code added in the code that ask for download and upgrade)

Discussion points

  • what if the structure ? main RN concept ?
  • use Metro with some adapted features ?
  • use other existing APIs ?
  • some codes ,

thanks

I would want to discuss about how and what to develop or use that exist to put inside the app and inside an API to do that feature described

I believe what you're trying to do is over the air updates. I would suggest to look into those two solutions that already exists:
https://learn.microsoft.com/en-us/appcenter/distribution/codepush/
https://docs.expo.dev/eas-update/introduction/

hi , thank you.
yes , it is a "over the air update" but limited to Android.
So I do not work with Expo because I integrate hardware , so react Native is the tool.
And as far as IBM is concerned, I do not want to depend of Google, so of course not depend of Microsoft... and let all my poor margin to them.
I want a more private simple on-air-repo .
No I am looking of a sort of node API that runs like a service on my PC (like pm2 for example) and answers to an android call from my app.

And why to you close the discussion ?? (I can do it myself if satisfied !)

I want a more private simple on-air-repo .

You will then have to create your own mechanism to download and update the JS bundle.
Feel free to share your solution or your proof of concept with the community.

the problem is that I do not understand the process of installation of METRO , and if YOU close the discussion issues as you do : you will nether have any results !!!! Thank you for having reopened the discussion.

We have to understand how :

  1. generate a JS bundle
  2. (so make a zip of it with app version if no package.json, zip of the app name, ending with a dedicated extention "prp" for ex.
  3. write a process that with fetch the .prp package (easy) through an API (easy) and store it in dowload dir on Android, unzip it
  4. install the JS bundle
  5. restart the app or make it run with the new bundle.

I need to know how please to do steps 1, 4 and 5

I've not done this but I believe this is the gist of what you want based on my knowledge of RN + the way react-native-code-push installation works.

  1. generate a JS bundle

You can use npm react-native bundle to do this, run with --help to see the options you can/will supply (like which platform you're building for and if it's a dev build or not).

  1. install the JS bundle

Up to you how you wish to store it locally in the filesystem, the important thing is it needs to be somewhere accessible for step 5.

  1. restart the app or make it run with the new bundle.

For iOS - you need to make your new file available here in some manner:

https://github.com/facebook/react-native/blob/76c7ccaa60c4e820757c5d8cd8ccc80a2cb5f4a0/template/ios/HelloWorld/AppDelegate.mm#L18

For Android - you want to add a new override method to the ReactNativeHost setup here:

https://github.com/facebook/react-native/blob/76c7ccaa60c4e820757c5d8cd8ccc80a2cb5f4a0/template/android/app/src/main/java/com/helloworld/MainApplication.java#L16

                @Override
                protected String getJSBundleFile() {
                    return 'path to file';
                }

Thank you @liamjones , I have so I think all that I need to start a dev on it !
I keep you posted here , and I will close this issue when finised or at least in release, promise!

So , some news and new questions: per step:
1/ bundle creation :
$ npx react-native bundle --entry-file index.js --platform "android" --minify "true" --bundle-output ./.bundle/bundle --sourcemap-output ./.bundle/map --assets-dest ./.bundle/assets
will create all the files under ./.bundle of the project

As for step 5, I do not understand what to do inside what @liamjones suggests, because I do not have those files inside a project (created by npx react-native init) : could you correct the idea within a react native project structure please ?
thank you !

I just have created a public project

hi, I will study the existing project : https://github.com/shm-open/code-push-server