Hello Friends 👋,
Welcome To Infinitbility! ❤️
React Native provide platform module to check some basics detaile related to device and applicatuion like version, os, and etc.
Today, we use react native platform os module to check device is a android or ios and write some code dependent upon device os.
Platform.OS
will return android when runing in Android device and return ios when runing in iOS device.
Let see how we can get device os name using Platform.OS
.
First of all we have to import
Platform
from react native package after sucessfully import Platform
simply we can use Platform.OS
everywhere in react native code.
1import { Platform, StyleSheet } from 'react-native';
Platform.OS use in StyleSheet example
1const styles = StyleSheet.create({2 height: Platform.OS === 'ios' ? 200 : 1003});
Platform.OS use in functions example
1getDeviceOs = () => {2 return Platform.OS; // it will return ios, or android3}
Thanks for reading…
Follow me on Twitter
Join our email list and get notified about new content
No worries, I respect your privacy and I will never abuse your email.
Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.