Pra*_*ati 11 react-native react-native-android
最后,react native bridge 是唯一的方法。但是有没有对任何人都成功的 npm 包?
rid*_*tun 26
您可以使用链接库打开您的应用程序设置。
import {Linking} from 'react-native';
Linking.openSettings();
Run Code Online (Sandbox Code Playgroud)
官方文档:https : //reactnative.dev/docs/linking#opensettings
Fre*_*man 16
结合现有的答案:这对我来说适用于 iOS 和 Android(没有博览会)
import { Linking, Platform } from 'react-native';
const handleOpenSettings = () => {
if (Platform.OS === 'ios') {
Linking.openURL('app-settings:');
} else {
Linking.openSettings();
}
};
// add a button that calls handleOpenSetttings()
Run Code Online (Sandbox Code Playgroud)
rid*_*tun 14
您可以使用@react-native-community/react-native-permissions库。
这里官方文档:https : //github.com/react-native-community/react-native-permissions#opensettings
例子:
import { openSettings } from 'react-native-permissions';
openSettings();
Run Code Online (Sandbox Code Playgroud)
从react-native核心链接API提供了将自定义意图操作发送到Android的功能。
注意 - 您可以发送 Android 可接受的任何自定义操作,此外您还可以将数据传递给意图。
这是打开设置的示例:
import {Linking} from 'react-native';
// To open settings
Linking.sendIntent('android.settings.SETTINGS');
// To open GPS Location setting
Linking.sendIntent('android.settings.LOCATION_SOURCE_SETTINGS');
Run Code Online (Sandbox Code Playgroud)
希望这会对您或其他人有所帮助。谢谢!
快乐编码:-)
| 归档时间: |
|
| 查看次数: |
10508 次 |
| 最近记录: |