'react native redirect to the settings update OS
Hey so i need to check if the user device is older version if yes i will show alert that tell to update and if press on button "UPDATE" i want to take to the screen of the OS to UPDATE.
thanks for anyone who can help!
export const CheckOsVersion: FC = () => {
useEffect(() => {
const currentOS = Platform.OS;
const currentVersion = Number(Platform.Version);
const LATEST_VERSION_ANDROID = 34;
const LATEST_VERSION_IOS = 13;
const MAX_DIFF_VERSION = 2;
if (currentOS === 'android') {
if (LATEST_VERSION_ANDROID - currentVersion > MAX_DIFF_VERSION) {
Alert.alert(
'text',
'“text.',
[
{
text: 'NOT NOW',
onPress: () => console.log('Cancel Pressed'),
style: 'cancel',
},
{
text: 'Update',
onPress: () => console.log('Update Pressed'),
},
],
{ cancelable: false },
);
}
} else if (currentOS === 'ios') {
if (LATEST_VERSION_IOS - currentVersion > MAX_DIFF_VERSION) {
Alert.alert(
'text',
'“text.',
[
{
text: 'NOT NOW',
onPress: () => console.log('Cancel Pressed'),
style: 'cancel',
},
{
text: 'Update',
onPress: () => console.log('Update Pressed'),
},
],
{ cancelable: false },
);
}
}
}, []);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
