如何访问本地反应博览会应用程序的位置权限设置?

时间:2019-05-24 16:09:04

标签: react-native expo

我知道我们可以使用IntentLauncherAndroid

访问某些android设置

我当前的代码如下:

import { IntentLauncherAndroid as IntentLauncher } from 'expo';

// onClick function to access app's permission settings
onPressButton = () => {
  IntentLauncher.startActivityAsync(IntentLauncher.ACTION_SETTINGS)
}

虽然目前该按钮仅打开手机的常规设置。

1 个答案:

答案 0 :(得分:0)

此代码应该是您想要的,您可以使用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
  )
}
相关问题