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.

import { Platform, StyleSheet } from 'react-native';

Platform.OS use in StyleSheet example

const styles = StyleSheet.create({
  height: Platform.OS === 'ios' ? 200 : 100
});

Platform.OS use in functions example

getDeviceOs = () => {
    return Platform.OS; // it will return ios, or android
}

Thanks for reading…