El *_*rio 5 javascript settings react-native
您好,我尝试遵循 YouTube 上的教程,了解如何在用户未启用位置服务的情况下使应用程序打开位置设置。然而在他的电脑上它可以工作(尽管他使用的是android模拟器),而我的Iphone XS(我相信它可以在最新的IOS版本上工作)却没有做任何事情。
我尝试仅打开设置,甚至打开互联网上的链接,但它不起作用
openSetting = () => {
if(Platform.OS=='ios'){
Linking.openURL('app-settings:')
}
else{
IntentLauncherAndroid.startActivityAsync(
IntentLauncherAndroid.ACTION_LOCATION_SOURCE_SETTINGS
);
}
this.setState({openSetting:false});
}
Run Code Online (Sandbox Code Playgroud)
<Button onPress={() => this.setState({isLocationModalVisible:false, openSetting:true})}
title ="Enable Location Services"/>
Run Code Online (Sandbox Code Playgroud)
我想你只需要调用这个函数就可以了。我已经检查了您的代码,它在两个平台上都运行良好
<Button onPress={() => this.openSetting()} title ="Enable Location Services"/>
Run Code Online (Sandbox Code Playgroud)
同时调用setState
<Button onPress={() => {this.openSetting();
this.setState({isLocationModalVisible:false, openSetting:true})}}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6252 次 |
| 最近记录: |