Skip to content

Commit

Permalink
Add a section about Platform.Version on iOS
Browse files Browse the repository at this point in the history
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 #14437

Differential Revision: D5250499

Pulled By: hramos

fbshipit-source-id: 29d1323e443fc1c5710283515c4233a192d354a0
  • Loading branch information
zubko authored and facebook-github-bot committed Jun 15, 2017
1 parent 2cc1195 commit 390c8cf
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/PlatformSpecificInformation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 390c8cf

Please sign in to comment.