gpt4 book ai didi

android - 使用 native react 检查是否启用了位置服务

转载 作者:可可西里 更新时间:2023-11-01 03:31:34 27 4
gpt4 key购买 nike

我目前正在开发一款使用 React Native 的应用程序,该应用程序的某些功能需要启用定位服务。我一直在研究是否有一种简单的方法来测试用户是否打开了它们,这样我就可以在没有打开的情况下显示不同的 View 。除了特定于 IOS 或 Android 的结果外,我没有找到任何结果。还有其他人找到解决方案吗?

最佳答案

为android使用“react native android location services dialog box”模块

https://www.npmjs.com/package/react-native-android-location-services-dialog-box

安装

npm install react-native-android-location-services-dialog-box --save

js

import LocationServicesDialogBox from "react-native-android-location-services-dialog-box";

LocationServicesDialogBox.checkLocationServicesIsEnabled({
message: "Use Location ?",
ok: "YES",
cancel: "NO"
}).then(function(success) {
console.log(success); // success => "enabled"
).catch((error) => {
console.log(error.message); // error.message => "disabled"
});

关于android - 使用 native react 检查是否启用了位置服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36776780/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com