android - react 原生 : How to open OS settings in Android and iOS?

标签 android ios react-native settings

我正在开发 手机使用 的应用程序 react 原生 我要在其中打开移动设备的设置 当用户点击在特定按钮上。

我已经通过文档 注册护士,但仍然是 找不到 任何可以帮助我实现相同目标的东西。有人可以指导 我也一样,那怎么实现?

谢谢 :)

最佳答案

在我的情况下,我想将用户发送到 蓝牙设置CR7答案对我不起作用。
所以,我使用以下方法解决了这个问题:

  • IOS: Linking来自 react-native
  • 安卓: AndroidOpenSettings来自 react-native-android-open-settings

  • 我还使用了Platform来自 react-native检查当前设备是否为 IOS。
    见代码:
    ...
    import {Linking, Platform} from 'react-native';
    import AndroidOpenSettings from 'react-native-android-open-settings';
    ...
    
    ...
    const goToSettings = () =>
      Platform.OS === 'ios'
        ? Linking.openURL('App-Prefs:Bluetooth')
        : AndroidOpenSettings.bluetoothSettings();
    ...
    
    ...
    return (
    <TouchableOpacity onPress={() => goToSettings()}>
      <Text>Go to settings</Text>
    </TouchableOpacity>
    );
    ...
    

    关于android - react 原生 : How to open OS settings in Android and iOS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61485805/

    相关文章:

    ios - Google Firebase 登录完成后从 AppDelegate 导航到 ViewController

    ios - POST header 和正文之间的随机延迟

    ios - 我现在可以对要通过商店分发的 iOS 应用程序使用 JIT 吗?

    react-native - 从 API 获取错误地在 Android 上返回旧的 "cached"数据,在 iOS 上返回最新数据

    android - 仅从媒体存储中获取前 100 行图像

    android - 启用 viewBinding 功能失败(Android Studio 3.6)

    android - 当应用程序被强制关闭或设备重新启动时,共享首选项会重置数据

    react-native - 单击 React Native 中的图标打开菜单

    reactjs - 用户界面小猫 : can't find variable index (BottomNavigation)

    android - MonkeyRunner:更可靠的等待和全长截图?