iOS8中的定位服务
iOS8中的定位服务

My app that worked fine in iOS 7 doesn't work with the iOS 8 SDK.
CLLocationManager doesn't return a location, and I don't see my app under Settings > Location Services either. I did a Google search on the issue but nothing came up, what could be wrong?
我的应用在iOS7上运行得好好的,但是到了iOS8上就出问题了.
在iOS8中,CLLocationManager并没有返回一个地址,而且,我也没有在Settings>Location Services中找到该服务,在Google上也没查到类似的问题,请问到底哪里出问题了?
I ended up solving my own problem.
Apparently in iOS 8 SDK, requestAlwaysAuthorization (for background location) or requestWhenInUseAuthorization (location only when foreground) call on CLLocationManager is needed before starting location updates.
There also needs to be NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription key in Info.plist with a message to be displayed in the prompt. Adding these solved my problem.
Hope it helps someone else.
最后我解决了这个问题.
在iOS8的sdk中,你需要额外的requestAlwaysAuthorization(用作后台定位)以及requestWhenInUseAuthorization(用作前台定位),在调用CLLocationManager更新地址之前你都需要调用上述两个方法.你还需要在Info.plist文件中额外的添加NSLocationAlwaysUsageDescription以及NSLocationWhenInUseUsageDescription,这么做了之后才解决了我的问题.
According to the Apple docs:
As of iOS 8, the presence of a NSLocationWhenInUseUsageDescription or a NSLocationAlwaysUsageDescription key value in your app's Info.plist file is required. It's then also necessary to request permission from the user prior to registering for location updates, either by calling [self.myLocationManager requestWhenInUseAuthorization] or [self.myLocationManager requestAlwaysAuthorization] depending on your need. The string you entered into the Info.plist will then be displayed in the ensuing dialog.
If the user grants permission, it's business as usual. If they deny permission, then the delegate is not informed of location updates.
根据苹果的官方文档:
在iOS8上,你需要在你的plist文件中添加新的键值NSLocationWhenInUseUsageDescription或者NSLocationAlwaysUsageDescription.然后,每次定位的时候你都需要获取用户的授权信息,通过调用[self.myLocationManager requestWhenInUseAuthorization] 或者[self.myLocationManager requestAlwaysAuthorization],至于调用哪一个,这就根据你自己的需求了.那个你添加进plist文件中的键值信息会在确认的信息中有提示.
如果用户允许你定位,你可以像往常那样子使用定位功能.如果他们拒绝了,那么,这个定位的更新更能永远也不会被执行.
iOS8中的定位服务的更多相关文章
- iOS开发手记-iOS8中使用定位服务解决方案
问题描述: 在iOS8之前,app第一次开始定位服务时,系统会弹出一个提示框来让用户选择是否允许使用定位信息.但iOS8后,app将不会出现这个弹窗.第一次运行之后,在设置->隐私->定位 ...
- iOS8 无法设置定位服务
针对iOS8系统,需要在plist文件中添加这两个参数 NSLocationAlwaysUsageDescription = YES NSLocationWhenInUseUsageDescripti ...
- IOS定位服务的应用
IOS定位服务的应用 一.授权的申请与设置 二.定位服务相关方法 三.定位服务代理的相关方法 四.定位服务获取到的位置对象 五.航标定位得到的航标信息对象 IOS定位服务的应用 一.授权的申请与设置 ...
- 【Android】18.1 利用安卓内置的定位服务实现位置跟踪
分类:C#.Android.VS2015: 创建日期:2016-03-04 一.安卓内置的定位服务简介 通常将各种不同的定位技术称为位置服务或定位服务.这种服务是通过电信运营商的无线电通信网络(如GS ...
- iOS8中定位服务的变化(CLLocationManager协议方法不响应,无法回掉GPS方法,不出现获取权限提示)
最近在写一个LBS的项目的时候,因为考虑到适配iOS8,就将项目迁移到Xcode6.0.1上,出现了不能正常获取定位服务权限的问题. self.manger = [[CLLocationManager ...
- 解决在iOS8环境下,当用户关闭定位服务总开关时,无法将APP定位子选项加入定位权限列表的问题
关键点:- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizati ...
- 在iOS8下使用CLLocationManager定位服务需要系统授权
最近在ios8.0使用CLLocationManager定位服务,发现老不能定位,查看设置菜单中的项也是处于未知状态.想起之前都有一个弹出框提示用户是否允许定位,这次一直没有出现了.原来ios8.0下 ...
- 系统定位在iOS8中的改变
CLLocationManager这个系统定位的类在iOS8之前要实现定位,只需要遵守CLLocationManagerDelegate这个代理即可: - (void)startLocate { ...
- iOS8中使用CoreLocation定位[转]
本文转自:http://blog.devzeng.com/blog/ios8-corelocation-framework.html iOS8以前使用CoreLocation定位 1.首先定义一个全局 ...
随机推荐
- mysql时间字符串按年/月/天/时分组查询 -- date_format
SELECT DATE_FORMAT( deteline, "%Y-%m-%d %H" ) , COUNT( * ) FROM test GROUP BY DATE_FORMAT( ...
- SparkSQL简介
1.SparkSQL的发展历程 1.1 Hive and Shark SparkSQL的前身是Shark,给熟悉RDBMS但又不理解MapReduce的技术人员提供快速上手的工具,Hive应运而生,它 ...
- onkeydown事件
<img src="images/hot.jpg" alt="" id="imgId" class="img1"/ ...
- vue router的浏览器跳转行为
最近做的项目中,涉及vue router 路由操作,其操作方法不同,产生的行为亦不同.本文通过对比实验,对其行为进行实验对比及总结,避免混淆. vue router的单页跳转的history模式,类似 ...
- 开源方案搭建可离线的精美矢量切片地图服务-4.Mapbox样式设计
项目成果展示(所有项目文件都在阿里云的共享云虚拟主机上,访问地图可以会有点慢,请多多包涵). 01:中国地图:http://test.sharegis.cn/mapbox/html/3china.ht ...
- java date相关
public static void getPreDay() throws ParseException{ String dateStr="2013-1-1"; D ...
- 初学nodejs之安装Express中遇到的问题: error: option `-v, --view <engine>' argument missing
Windows安装下载nodejs地址:http://nodejs.org/download/ node -v 查看安装版本,输出版本即安装成功 之前学习了nodejs的基础,今天安装Express框 ...
- .net core 2.2 部署CentOS7(2)给虚拟机安装CentOS7
目录: .net core 2.2 部署CentOS7(1)安装虚拟机 .net core 2.2 部署CentOS7(2)给虚拟机安装CentOS7 .net core 2.2 部署CentOS7( ...
- ios app真正的相互!!调用
1.需求:A应用打开B.B回跳到A 2.问题: 看到网络上的文档讲的大多数都是app单向跳转的例子,而我们在跳转到第二个app的时候往往需要返回到原来的app,虽然支付宝微信等第三方等应用会有回调 ...
- SpringBoot(一)初遇
环境: IDEA 2018.1.3 , jdk 1.8 , maven 3.3.9 零 第一次接触springboot, 如何学习比较困惑, 思前想后最后决定从文档来学习, 以下为学习中的参考资料: ...