Closed strdr4605 closed 4 years ago
Hi there! Well, sort of. Here's what it can do on iOS - it can check for a version file (JSON format) and compare version codes to indicate if there is a new version or not. From there you can do what you like with regard to user messaging and redirection to the App Store at your apps URL or similar, but as far as I know for most devices there is no way to install an app so it cannot actually update things.
I use it this way still though, in order to pop notifications to users that they should update
The version file is in the app? and it compares it with the actual app from the App Store?
Ah - I just checked and I actually do it all outside this module, sorry for the confusion!
checkIOSUpdate(foreground = true, showIfCurrent = false) {
console.log('APKUpdateService::checkIOSUpdate starting');
fetch(AppConfig.getAppVersionUrl())
.then(response => response.json())
.then(async responseData => {
console.log('APKUpdateService::checkIOSUpdate received', responseData);
if (parseInt(responseData.versionCode) > parseInt(DeviceInfo.getBuildNumber())) {
console.log(
'APKUpdateService::checkIOSUpdate - have build ' + DeviceInfo.getBuildNumber()
);
console.log('APKUpdateService::checkIOSUpdate - inequal version codes, update?');
firebase.notifications().setBadge(1);
if (foreground) {
this.displayNewVersionAlert();
} else {
this.displayNewVersionNotification();
}
} else {
console.log('APKUpdateService::checkIOSUpdate - equal version codes');
firebase.notifications().setBadge(0);
if (foreground && showIfCurrent) {
RN.Alert.alert(
I18NService.translate('NoUpdateAvailableTitle'),
I18NService.translate('NoUpdateAvailableText'),
[{ text: 'OK', onPress: () => {} }]
);
}
}
})
.catch(e => {
console.log('APKUpdateService::checkIOSUpdate error', e);
});
}
Does this package also support iOS updates?