From 390c8cf96ee0b139aafc99bb23f8a49236f05309 Mon Sep 17 00:00:00 2001 From: Alexander Zubko Date: Thu, 15 Jun 2017 09:19:21 -0700 Subject: [PATCH] Add a section about Platform.Version on iOS Summary: The docs don't have a section about `Platform.Version` on iOS, but it's available. Very simple change. I've used the section for Android as an example. Closes https://github.com/facebook/react-native/pull/14437 Differential Revision: D5250499 Pulled By: hramos fbshipit-source-id: 29d1323e443fc1c5710283515c4233a192d354a0 --- docs/PlatformSpecificInformation.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/PlatformSpecificInformation.md b/docs/PlatformSpecificInformation.md index 324d7b27d9e374..bb49df3eca7a6d 100644 --- a/docs/PlatformSpecificInformation.md +++ b/docs/PlatformSpecificInformation.md @@ -77,6 +77,19 @@ if (Platform.Version === 25) { } ``` +### Detecting the iOS version + +On iOS, the `Version` is a result of `-[UIDevice systemVersion]`, which is a string with the current version of the operating system. An example of the system version is "10.3". For example, to detect the major version number on iOS: + +```javascript +import { Platform } from 'react-native'; + +const majorVersionIOS = parseInt(Platform.Version, 10); +if (majorVersionIOS <= 9) { + console.log('Work around a change in behavior'); +} +``` + ## Platform-specific extensions When your platform-specific code is more complex, you should consider splitting the code out into separate files. React Native will detect when a file has a `.ios.` or `.android.` extension and load the relevant platform file when required from other components.