如何重定向到仅适用于android 12的react本机应用程序设置?
NativeModules.OpenSettings.openNetworkSettings(() => null);我现在不能用那个代码
import { openSettings } from 'react-native-permissions';
openSettings();这也不适合我
发布于 2022-11-17 12:16:46
你试过这个吗?
const Screen = () => (
<Button
title="Open Settings"
onPress={() => {
Linking.openSettings();
}}
/>
);别忘了进口
import { Button, Linking } from "react-native";发布于 2022-11-17 13:27:22
首先,您必须查阅Reacti原住民的官方文档,您可以找到这个问题的解决方案。
代码:
<TouchableOpacity
onPress={() => {
Linking.openSettings();
}}
style={{
paddingHorizontal: 80,
paddingVertical: 10,
backgroundColor: '#326A81',
}}>
<Text style={{color: 'white'}}>Open Setting</Text>
</TouchableOpacity>发布于 2022-11-17 15:42:18
下面的内容应该适用于android和ios。
import { Linking, Platform } from 'react-native';
const handleOpenSettings = () => {
if (Platform.OS === 'ios') {
Linking.openURL('app-settings:');
} else {
Linking.openSettings();
}
};https://stackoverflow.com/questions/74474774
复制相似问题