Navigate back to the homepage

How to check if device is android or ios in react native

Infinitbility
React Native
September 5th, 2021 · 1 min read
How to check if device is android or ios in react native

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 : 100
3});

Platform.OS use in functions example

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

Thanks for reading…

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.

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Tutorials

React Native

Categories

More articles from Infinitbility

How to check connected devices in react native

How to check connected devices in react native

React Native check connected devices list example

September 4th, 2021 · 1 min read
How to check array contains value in javascript

How to check array contains value in javascript

Check array contains specfic item or not in Javascript, React, React Native, typescript, node, deno, next, vue, gatsby and all javascript library.

September 3rd, 2021 · 1 min read
© 2020–2021 Infinitbility
About
Link to $https://medium.com/infinitbilityLink to $https://www.facebook.com/InfinitbilityLink to $https://github.com/infinitbilityLink to $https://twitter.com/infinitbilityLink to $https://www.buymeacoffee.com/infinitbilityLink to $mailto:[email protected]