sp-react-native-in-app-updates
sp-react-native-in-app-updates copied to clipboard
Forced update show only once (explain below)
If the user kills the screen while the in-app-update is being downloading, the prompt to update will not show up again the next time the app is opened. next time it show shouldUpdate:false. Anyone facing same issue if not then please retry one more time.
this is the response I am getting
@ShravanMeena An update can be already downloaded. You need just install it. Despite the fact that shouldUpdate is false, you have a versionCode field and you can compare it with a versionCode (on android) of your app and in that case they will be different.
@ShravanMeena An update can be already downloaded. You need just install it. Despite the fact that shouldUpdate is false, you have a versionCode field and you can compare it with a versionCode (on android) of your app and in that case they will be different.
No it just shows me updated version but my app current version is below.
and if already downloaded, how do I install it at the beginning of the next app @Lepidopterolog ?
@ShravanMeena I just managed the same problem yesterday))
There are several flows. If you called the update and launched a new instance of the application, then 2 options are possible: 1. The update is still loading. 2. It is already loaded. In the second case, everything is simple - install it (the library has the installUpdate method). In the first one, wait until it is pumped, and then install it.
How to determine if an update is being downloaded or already downloaded? If you look at the Android documentation for updates, you will understand that this library does not provide all native features. As of now you need installStatus https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateInfo.html#installStatus() in the answer that sends the checkNeedsUpdate method, which is not there, but that's not a problem, because it's an easy fix, unfortunately it will have to be done with a patch (I mean patch-package).
What exactly should be done? - in general, here is an example: https://github.com/Hilokal/sp-react-native-in-app-updates/commit/5dc74713c5988f204dca02b2c1c7c5bf5ea66d91
I implemented it a little differently:
if (inAppUpdateInfo.installStatus !== AndroidInstallStatus.INSTALLED) {
return {
shouldUpdate: true,
storeVersion: newAppV,
other: { ...inAppUpdateInfo },
reason: '...',
}
}
And then it's all about js, everything is very simple. Checking that this is Android and one of the 2 cases:
installStatus === IAUInstallStatus.DOWNLOADED:
inAppUpdates.installUpdate()
installStatus === IAUInstallStatus.DOWNLOADING:
wait for it to install: inAppUpdates.addStatusUpdateListener(...)