检查位置服务是否使用反应本机启用 [英] Checking if location services are enabled using react native

查看:118
本文介绍了检查位置服务是否使用反应本机启用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个应用程序,使用反应本机,需要位置服务才能使用它的某些功能。我一直在研究是否有一个简单的方法来测试用户是否打开它们,如果不是,我可以显示不同的视图。除了特定于IOS或Android的结果之外,我还没有发现任何结果。是否有其他人找到了解决方案?

I am currently working on an app using react native that requires location services to be on for some of its features. I have been researching if there is a simple way to test if the user has them turned on or not so I can display a different view if they aren't. I have not found any results other than ones that are specific to IOS or Android. Has anyone else found a solution to this?

推荐答案

我能够通过显示错误消息来解决这个问题,被检索。

I was able to solve this by displaying an error message when the location could not be retrieved.

(error) => {
        this.setState({servicesOn: false}),
        console.log(error);
      },

这篇关于检查位置服务是否使用反应本机启用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆