Open Udit-takkar opened 2 years ago
I am experiencing a similar problem. Using 1.1.6.
In this line the dependency ends up comparing the buildNumber with the versionName. (f.e. 510 with 0.8.1) https://github.com/SudoPlz/sp-react-native-in-app-updates/blob/ed1080b6ab379dacd44d550933ad3a8937ca78af/src/InAppUpdates.android.ts#L119
The number and the string seen in UPDATE DEBUG: 10605 0.9.4
are the parameters newAppV, appVersion
the customComparator is getting.
@SudoPlz Did something change here on Google's or react-native-device-info's side?
@Udit-takkar @xtl-geiger did you guys manage to solve it?
Nope
I am using the latest version. I am not even getting the Store version. I am not sure what went wrong.
@Udit-takkar @xtl-geiger did you guys manage to solve it?
Yes I ended up using the buildNumber from DeviceInfo and comparing it using a customVersionComparator.
@Udit-takkar @xtl-geiger did you guys manage to solve it?
Yes I ended up using the buildNumber from DeviceInfo and comparing it using a customVersionComparator.
I had the same issue, can you give me your code snippet on how to implement customVersionComparator? @xtl-geiger
Anyone able to fix this/found a workaround? Also Is this issue with repo or google?
Hi @xtl-geiger can you provide more details that how have you resolved it?
So nobody else has to spend 2 hours solving this
inAppUpdates
.checkNeedsUpdate({
// Bug with library, as it tries to compare
// build number (on store) and version (on device)
// So, we manually pass in build number
curVersion: Platform.OS === 'android' ? curBuildNumber : undefined,
customVersionComparator:
Platform.OS === 'android'
? (v1, v2) => {
return v1 > v2 ? 1 : v1 < v2 ? -1 : 0;
}
: undefined,
})
It is not possible to obtain store version number instead of build number?
Same here, I absolutely need the store version number since we only want to compare the major part of the SemVer version. Is there a way to do that?
@pedrodlz @leabaertschi I doubt it is possible using this dependency at the moment, seeing as it uses Android's AppUpdateInfo
under the hood:
And AppUpdateInfo
only provides these values:
https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateInfo.html
Seeing as availableVersionCode
simply returns the Integer version code of your app build number and AppUpdateInfo
does not have a method to retrieve the store version of your app you would need to use a different approach to get the app version from the play store and compare it.
You could either query the play store for the version yourself or use a dependency to get the store version.
F.e.
https://github.com/watanabeyu/react-native-store-version
https://github.com/kimxogus/react-native-version-check
etc.
@leabaertschi You can use react-native-store-version to check the semantic version of the app on the App/Play store and then compare it with the installed app version.
@pedrodlz @leabaertschi I doubt it is possible using this dependency at the moment, seeing as it uses Android's
AppUpdateInfo
under the hood:And
AppUpdateInfo
only provides these values:https://developer.android.com/reference/com/google/android/play/core/appupdate/AppUpdateInfo.html
Seeing as
availableVersionCode
simply returns the Integer version code of your app build number andAppUpdateInfo
does not have a method to retrieve the store version of your app you would need to use a different approach to get the app version from the play store and compare it.You could either query the play store for the version yourself or use a dependency to get the store version.
F.e. https://github.com/watanabeyu/react-native-store-version https://github.com/kimxogus/react-native-version-check etc.
I have moved to https://github.com/kimxogus/react-native-version-check and works perfectly fine.
Thanks everyone, I'll have a look at the proposed modules.
On ios is it working fine but in android it is always returning shouldUpdate even though it is updated. the store version is returning versionCode instead of version.
phone:- OnePlus7 sp-react-native-in-app-updates: 1.1.7 "react-native": "0.64.0"