react-native - 如何访问我的 react-native expo 应用程序的位置权限设置?
问题描述
我知道我们可以使用访问某些 android 设置IntentLauncherAndroid
我目前的代码如下:
import { IntentLauncherAndroid as IntentLauncher } from 'expo';
// onClick function to access app's permission settings
onPressButton = () => {
IntentLauncher.startActivityAsync(IntentLauncher.ACTION_SETTINGS)
}
虽然目前该按钮仅打开手机的常规设置。
解决方案
此代码应该是您想要的,您可以使用 Intent Promise 来了解用户何时从 Intent 操作返回(https://docs.expo.io/versions/latest/sdk/intent-launcher/#returns)
import { IntentLauncherAndroid as IntentLauncher } from 'expo';
// onClick function to access app's permission settings
onPressButton = async () => {
const intent = await IntentLauncher.startActivityAsync(
IntentLauncher.ACTION_LOCATION_SOURCE_SETTINGS
)
}
推荐阅读
- css - Bootstrap 5 Carousel 宽度在 flexbox 祖先中增加了一倍
- flutter - 通过蓝牙将 GPS 数据从 Flutter 应用程序发送到 arduino
- azure-cli - az acr build 总是无法在 Windows 上运行
- swift - 在 WKWebView evaluateJavaScript 方法上,无法监听 dom 事件
- c# - 使用 EWS 的自动发现无法正常工作,具体取决于正在运行的机器
- reactjs - ReactJs TypeError:映射时无法读取null的属性(读取'localeCompare')
- amazon-web-services - 如何配置 IAM 角色为新的 EC2 实例启用 SSM?
- react-native - 反应原生的滚动视图不滚动
- python - python中的JSON遍历和编辑
- c# - Rigidbody2D:如何防止 Y 轴被 0 覆盖?