如何链接到iOS phonegap应用程序中的设置 - >隐私 - >位置服务 [英] How to link to Settings->Privacy->Location Services in iOS phonegap app

查看:191
本文介绍了如何链接到iOS phonegap应用程序中的设置 - >隐私 - >位置服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用phonegap来制作应用程式,当使用者不允许某些权限(例如GPS)时,该应用程式不会再次询问他们下次使用该功能,我认为最好的我可以做的只是显示这样的消息:



请转到iOS设置>隐私>位置服务,以启用该应用程序访问您的位置



但我只是注意到地图应用程序给出这个消息:



打开位置服务以允许地图确定您的位置



它可以选择设置或取消。如果您点击设置,它会直接到设置的位置服务部分,以便您可以启用它。



我的问题是,如何链接到

解决方案

在iOS> = 8中,您可以使用以下方法打开应用程序设置面板:

  NSURL * url = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; 
[[UIApplication sharedApplication] openURL:url];

这是很容易写一个cordova插件从js图层打开该面板。要创建可移植和稳定的插件,您应该在使用它之前检查该变量的存在(在iOS< 8)。



查看iOS UIApplication文档。 / p>

使用现有cordova设置插件


I'm using phonegap to make an app, and when a user doesn't allow a certain permission (GPS for example), then the app doesn't ask again the next time they use that feature and I thought the best I could do is just display a message like this:

Please go to iOS Settings > Privacy > Location Services to enable the app to access your location

But I just noticed that the maps app give this message:

Turn On Location Services to Allow Maps to Determine Your Location

And it has the option of Settings or Cancel. If you click Settings, it takes you right to the location services part of settings so that you can enable it.

My question is, how can I link to that part of settings with a phonegap app?

解决方案

In iOS >= 8 you can open the application setting panel using:

NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];

It's very easy to write a cordova plugin that open that panel from the js layer. To make a portable and stable plugin you should check for the existence of that variable before using it (in iOS < 8).

See the iOS UIApplication documentation for more information.

Ore use an existing cordova settings plugin.

这篇关于如何链接到iOS phonegap应用程序中的设置 - &gt;隐私 - &gt;位置服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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