【问题标题】:How to open application's location permission settings directly in React Native如何在 React Native 中直接打开应用的位置权限设置
【发布时间】:2021-02-22 10:16:10
【问题描述】:

REACTNATIVE : 目前使用 Linking.openSettings() 打开我的应用程序设置页面。

现在,我想直接打开应用程序权限屏幕,该屏幕位于应用程序设置中,以使用 REACT NATIVE 在 Android 和 iOS 中启用位置、存储等权限。

有什么可能吗?提前致谢!

【问题讨论】:

    标签: react-native permissions settings react-native-navigation


    【解决方案1】:

    很快就有可能,

    对于IOS操作系统,试试下面,

    import { Linking } from 'react-native'
    Linking.openURL('app-settings:')
    

    但是Android不能使用Linking,我们应该添加两个依赖,

    npm install --save react-native-device-info

    npm install react-native-intent-launcher

    因此,

    import DeviceInfo from 'react-native-device-info';
    import IntentLauncher, { IntentConstant } from 'react-native-intent-launcher'
    const package= DeviceInfo.getBundleId();
    const openAppSettings = () => {
      if (Platform.OS === 'ios') {
        Linking.openURL('app-settings:')
      } else {
        IntentLauncher.startActivity({
          action: 'android.settings.APPLICATION_DETAILS_SETTINGS',
          data: 'package:' + package
        })
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-17
      • 2018-11-13
      • 2022-11-05
      • 2018-01-31
      • 2022-11-24
      相关资源
      最近更新 更多