Basically what the title says. I am aware of the Platform component (https://reactnative.dev/docs/platform-specific-code) which can be used to check what device the app is running on. Although, from my understanding, if the app is running in a web browser on ios/android, Platform wouldn't identify if it's running as an app or in a browser. Can I maybe do something like document == 'undefined (true if browser, false if app)? I appreciate any guidance.
I'm using expo by the way.
import { Platform } from 'react-native';
if (Platform.OS === 'ios') {
// do something for ios
} else if (Platform.OS === 'android') {
// other thing for android
} else if (Platform.OS === 'web') {
// it's on web!
} else {
// you probably won't end up here unless you support another platform!
}
I would recommend following the full tutorial provided at the start of the Expo docs, the Handling platform differences section covers this and you may learn other valuable information from the other sections.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With