React Native In-App Update
React Native In-App Update is a library that does App updates within your app easily, making sure your users are always up to date. This library supports at the moment Android only.
🎉 Getting started
To get started and make sure to configure it well please learn more about Play Store in-app updates here first.
Install via repo
$ yarn add https://github.com/franznkemaka/react-native-in-app-update
Mostly automatic installation
$ react-native link rn-in-app-update
Manual installation
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
-
Add
import com.franznkemaka.RNInAppUpdatePackage;
to the imports at the top of the file -
Add
new RNInAppUpdatePackage()
to the list returned by thegetPackages()
method
-
Append the following lines to
android/settings.gradle
:include ':rn-in-app-update' project(':rn-in-app-update').projectDir = new File(rootProject.projectDir, '../node_modules/rn-in-app-update/android')
-
Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':rn-in-app-update')
ℹ️ Usage
; { // check for updates and show modal if available // on iOS this displays a warning as it not supported InAppUpdate;}
Suggest to restart app
{ InAppUpdate; InAppUpdate;}
Check out the following App example to see how it works in a real app.
Examples
🏗 API
Recap
-
FLEXIBLE
means that the update is for example optional and can be downloaded in the background while the user is using the app. -
IMMEDIATE
means that the update must be downloaded and a full screen is displayed while downloading. -
staleDays
defines the number of days after which an update is not FLEXIBLE but becomes IMMEDIATE instead, hence forcing the user to update.
Methods
checkUpdate(config: UpdatesConfigObject) :void
;
onUpdateDownloaded(callback: CallableFunction) :void
Fires when the update was in FLEXIBLE
mode and it finished downloading. With your callback you can show an alert to prompt the user to restart or something alike.
forceCompleteUpdate() :void
Use this function in onUpdateDownloaded
to terminate the update process by restarting the app.
🤝 Authors and acknowledgment
- @franznkemaka
- Thanks to @sandeshnaroju for his initial work done with react-native-in-app-update and with this article
📌 Roadmap
- 🤖 Add Android support
- 🍏 Add iOS Support
- ✨ Add Priority mode, as described here
❤️ Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
⚖️ License
This project is licensed under the MIT License