You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

react-native 0.64.1如何实现iOS 14.5版本直接跳转蓝牙设置页

iOS 14及以上系统已经封禁了大部分App-prefs:协议下直接跳转系统设置子页面的公开调用权限,你尝试的几种写法都是适配iOS10~13版本的旧方案,在iOS14.5版本中通过React Native默认的Linking调用确实只能跳转至系统设置首页。

以下是两种可行的实现方案:

方案1:跳转本App的权限设置页(官方允许,无审核风险,推荐)

苹果官方支持跳转当前App的专属权限设置页,页面内会直接展示蓝牙等你已申请的权限开关,用户可以直接操作蓝牙权限,可直接通过Linking实现:

import { Linking } from 'react-native';

Linking.openURL('app-settings:');

方案2:原生模块实现跳转系统蓝牙设置页(存在审核被拒风险)

如果业务要求必须跳转系统蓝牙的主设置页,需要自行封装iOS原生模块实现,步骤如下:

  1. 在你的React Native项目iOS工程中新建原生类BluetoothJump,代码如下:
#import <React/RCTBridgeModule.h>
#import <UIKit/UIKit.h>

@interface RCT_EXTERN_MODULE(BluetoothJump, NSObject)
RCT_EXTERN_METHOD(openBluetoothSettings)
@end

@implementation BluetoothJump
- (void)openBluetoothSettings {
  dispatch_async(dispatch_get_main_queue(), ^{
    NSURL *bluetoothUrl = [NSURL URLWithString:@"App-prefs:root=Bluetooth"];
    if ([[UIApplication sharedApplication] canOpenURL:bluetoothUrl]) {
      [[UIApplication sharedApplication] openURL:bluetoothUrl options:@{} completionHandler:nil];
    }
  });
}
@end
  1. 在iOS工程的Info.plist的LSApplicationQueriesSchemes数组中,新增元素App-prefs
  2. React Native侧调用方式:
import { NativeModules } from 'react-native';

NativeModules.BluetoothJump.openBluetoothSettings();

注意:该方案使用了苹果未公开的私有跳转协议,应用上线审核时有概率被拒,若要使用建议提前做好审核规避准备。

内容的提问来源于stack exchange,提问作者cirpel4

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.05 13:09:01