简体   繁体   English

在代码中确定应用程序是否在 Expo Go 中运行(在生产版本中)

[英]Determine in code if app runs in Expo Go or not (in production build)

I would like to determine in react native code if the app is running in Expo Go or as a stand-alone iOS/Android app.我想在本机代码中确定应用程序是在 Expo Go 中运行还是作为独立的 iOS/Android 应用程序运行。

I can't use __DEV__ , because I would like to be able to determine this also for a production build.我不能使用__DEV__ ,因为我希望能够为生产构建确定这一点。

You can use Expo's AppOwnership from Constants您可以从Constants中使用 Expo 的AppOwnership

import Constants from 'expo-constants'

const isRunningInExpoGo = Constants.appOwnership === 'expo'

source 资源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我的 Expo 应用程序运行在 Expo Go 而不是开发版本? - Why does my Expo app run in Expo Go but not as a development build? Expo 打印在 Expo go 中有效,但在构建 apk 中无效 - Expo Print works in Expo go but not in build apk Expo:“Withnavigation”和“gorhom/bottom-sheet”导致应用在生产模式和应用构建时卡在启动画面 - Expo: ‘Withnavigation’ & ‘gorhom/bottom-sheet’ is causing the app to get stuck at Splash Screen on the production mode & app build 独立 Expo 应用程序和 expo go 之间的区别 - difference between standalone Expo app and expo go Expo 推送通知适用于 expo go 但不适用于 apk(生产) - Expo push notifications working on expo go but not working on apk ( production ) Expo 是否能够在不需要 Mac 的情况下构建可用于生产的 iOS 应用程序? - Is Expo able to build a production-ready iOS app without needing a Mac? Expo 在生产构建中找不到“主要”应用程序? - Expo does not find "main" application in production build? Expo 应用程序在 ios 和模拟器上运行,但不在 android 设备上运行 - Expo app runs on ios and emulator but not on android device 在Production React Native Expo App中登录设备 - Logging to Device in Production React Native Expo App Expo 用于开发、UAT 和生产的应用环境 - Expo App environments for Dev, UAT and Production
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM