This is my DeviceUtils.ts
file to reuse that logic. This could be greatly improved, happy to hear suggestions.
export const getMajorVersionIOS = (): number => {
if (Platform.OS != 'ios' ) {
throw Error("Platform is not iOS");
}
return parseInt(Platform.Version, 10);
}
export const getMinorVersionIOS = (): number => {
if (Platform.OS != 'ios' ) {
throw Error("Platform is not iOS");
}
return parseInt(
Platform.Version.substring(
Platform.Version.indexOf('.') + 1
)
, 10);
}
export const isIOSAbove14Point5 = (): boolean => {
if (Platform.OS === 'ios' ) {
const majorVersion = getMajorVersionIOS();
const minorVersion = getMinorVersionIOS();
if (majorVersion >= 15) return true;
if (majorVersion === 14 && minorVersion >= 5) return true;
}
// It's not iOS or it's not above 14.5
return false;
}
return majorVersion < major || (majorVersion === major && minorVersion < minor)
– Rauscher