本文永久地址为 http://www.cnblogs.com/ChenYilong/p/4020359.html,转载请注明出处。
iOS8的定位和推送的访问都发生了变化,

下面是iOS7和iOS8申请定位权限时的不同:


iOS7:

 
本文永久地址为 http://www.cnblogs.com/ChenYilong/p/4020359.html,转载请注明出处。
 

iOS8:

 
 
 
 
本文永久地址为 http://www.cnblogs.com/ChenYilong/p/4020359.html,转载请注明出处。
 
或者在真机上这样:
 
 
本文永久地址为 http://www.cnblogs.com/ChenYilong/p/4020359.html,转载请注明出处。
我们知道苹果在iOS8上对定位进行了大幅度优化,可以支持室内定位,常去地点统计,楼层等。但是在iOS8上currentLocation是空的,导致定位失败了。
高德也定位失败(原因可能是未对iOS8做适配),或者不会调用到定位之后的delegate方法中,然后我查看了一下手机上对应用的定位权限界面,发现我的应用的访问用户的地理位置的权限是空的,之后查了相关信息,得到以下解决方案:
iOS新增了下面的方法:
 
⓵requestWhenInUseAuthorization
⓶requestAlwaysAuthorization
用法

1.在AppDelegate中或者其它设置CLLocationManager的控制器中:

声明
@property(nonatomic,strong)CLLocationManager*locationManager;

实现中添加如下代码
   [UIApplicationsharedApplication].idleTimerDisabled = TRUE;
   self.locationManager = [[CLLocationManager alloc]init];
   self.locationManager.delegate = self;
   self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
   if(IS_IOS8){
[   self.locationManager requestAlwaysAuthorization];
   //NSLocationAlwaysUsageDescription
    [self.locationManager requestWhenInUseAuthorization];
   //NSLocationWhenInUseUsageDescription
}
    [self.locationManager startUpdatingLocation];

或者这样:

 

if([CLLocationManager locationServicesEnabled])

{

    self.locationManage = [[[CLLocationManager alloc] init] autorelease];

    self.locationManage.delegate = self;

    ;

    self.locationManage.desiredAccuracy = kCLLocationAccuracyBestForNavigation;

    //kCLLocationAccuracyBest;

    if (SYSTEM_VERSION >= 8.0) {

        //使用期间

        [self.locationManage requestWhenInUseAuthorization];

        //始终

        //or

        [self.locationManage requestAlwaysAuthorization]

    }

}

另外也提供下新增下面的代理方法:

 

- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status

{

    switch (status) {

        case kCLAuthorizationStatusNotDetermined:

            if ([self.locationManage respondsToSelector:@selector(requestAlwaysAuthorization)])

            {

                [self.locationManage requestWhenInUseAuthorization];

            }

            break;

        default:

            break;

    }

    

}

详情见https://app.yinxiang.com/l/ABarZZCJ2_dAd7B0ncWryoyV2bZ06fI1_WM

 

在AppDelegate是这样设置的:

 

@interface AppDelegate()<CLLocationManagerDelegate>

{

    UINavigationController *_navController;

    CLLocationManager      *_locationmanager;

}

 

@end

 

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

    [UIApplicationsharedApplication].idleTimerDisabled = TRUE;

    

    _locationmanager = [[CLLocationManager alloc] init];

    [_locationmanager requestAlwaysAuthorization];        //NSLocationAlwaysUsageDescription

    [_locationmanager requestWhenInUseAuthorization];     //NSLocationWhenInUseUsageDescription

    _locationmanager.delegate = self;

//....

}

本文永久地址为 http://www.cnblogs.com/ChenYilong/p/4020359.html,转载请注明出处。

2.并需要plist文件中进行设置:
设置方法:
 在 info.plist里加入:
    NSLocationWhenInUseUsageDescription,允许在前台获取GPS的描述
    (网上广为流传的NSLocationWhenInUseDescription,是不正确的,亲测不可行.请参照官方文档,链接已在文章结尾处给出.)
    NSLocationAlwaysUsageDescription,允许在后台获取GPS的描述
  如下图:

具体的文字提示,可以参照微信
你将得到这样的效果:
 
 
 
 
也可以这样设置:
 
你将得到这样的效果:
 
 
‘友情提示:如果你的应用开启了在后台运行GPS,必须在App的iTunes介绍里,加一句"Continued use of GPS running in the background can dramatically decrease battery life.”,否则苹果会把你的App拒掉….亲测是的….

Reasons:

  • 2.16: Multitasking Apps may only use background services for their intended purposes: VoIP, audio playback, location, task completion, local notifications, etc. 

Hello,

We found the following rejection while reviewing your app. Please see more details below.

We found that your app uses a background mode but does not include the following battery use disclaimer in your Application Description:

"Continued use of GPS running in the background can dramatically decrease battery life."

It would be appropriate to revise your Application Description to include this disclaimer.

If your iTunes Connect Application State is Metadata Rejected, we do NOT require a new binary. 

To revise the metadata:

- Log in to iTunes Connect
- Click on “My Apps”
- Select your app
- Revise the desired metadata values 
- Click “Save" 
- Once you’ve completed all changes, click the “Submit for Review” button at the top of the App Details page

Kind Regards,

The App Review Team

 
 
 
你模仿高德地图等应用,这样写:
【温馨提示】
本App的主要服务会持续使用GPS定位服务,切换至后时,仍会继续,相比其他操作会消耗更多的电量,并影响电池续航时间。
使用位置共享过程中,您可以随时退出,中止位置共享。本App不会将您的真实位置暴漏或提供给第三方。
Continued use of GPS running in the background can dramatically decrease battery life.
添加以上内容之后即可以进行定位服务,下面的一些问题#解决方案#也是如此:
  1. iOS8 高德地图SDK MAMapView无法定位的问题(http://blog.csdn.net/johnzhjfly/article/details/39497751)
  2. iOS8 百度地图SDK MAMapView无法定位的问题
  3. iOS8 Location not accessible
  4. iOS8 MKMapView 代理无效问题
  5. Access the user's location on Today Extension 
  1. iOS8无法开启定位问题
本文永久地址为 http://www.cnblogs.com/ChenYilong/p/4020359.html,转载请注明出处。

 

扩展阅读:
  1. iOS8 定位新增功能(http://blog.csdn.net/yongyinmg/article/details/39521523)
  2.  
 
 
另外这是iOS8申请push权限也变了,其api也变了
 
请注意,在此不做赘述.
 
 
本文永久地址为 http://www.cnblogs.com/ChenYilong/p/4020359.html,转载请注明出处。

https://developer.apple.com/library/IOs/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html

老项目的#iPhone6与iPhone6Plus适配#iOS8无法开启定位问题和#解决方案#的更多相关文章

  1. 系列文章:老项目的#iPhone6与iPhone6Plus适配#(持续更新中,更新日期2014年10月12日 星期日 )

    本文永久地址为http://www.cnblogs.com/ChenYilong/p/4020399.html ,转载请注明出处. ********************************** ...

  2. 老项目的#iPhone6与iPhone6Plus适配#LaunchImage适配

    本文永久地址为 http://www.cnblogs.com/ChenYilong/p/4020384.html,转载请注明出处.  Evernote印象笔记链接:https://www.everno ...

  3. 老项目的#iPhone6与iPhone6Plus适配#Icon适配

        本文永久地址为http://www.cnblogs.com/ChenYilong/p/4020373.html ,转载请注明出处.  这是Evernote印象笔记的链接:https://www ...

  4. 老项目的#iPhone6于iPhone6Plus适配#iPhone6分辨率与适配

    技术博客http://www.cnblogs.com/ChenYilong/    本文永久地址为http://www.cnblogs.com/ChenYilong/p/4011744.html ,转 ...

  5. #iPhone6与iPhone6Plus适配#如何在Xcode 6中创建 PCH 文件

    本文永久链接http://www.cnblogs.com/ChenYilong/p/4008086.html   新建文件 ⌘+N选择 iOS/Mac -> Other -> PCH Fi ...

  6. iOS开发之#iPhone6与iPhone6Plus适配#Xcode6.0/Xcode6.1上传应用过程中一些变动以及#解决方案#

    更新时间2014年11月13日  本博文创建时,只有Xcode6.0, Xcode6.0尝试多次,确实如此 之后在6.1版本经博主少量尝试,确实也有如下问题,现更新下博客! iOS8发布之后,苹果强制 ...

  7. 【实战】记一次老项目的swagger整合

    1.背景 这两天接到一个整合swagger的任务,本以为很简单,预计两小时内完成,没想到其中有太多的坑,整了两天才完成. 首先项目是一个比较老的项目,之前用的servlet,目前在重构为springm ...

  8. 搜刮一些开源项目的APP

    iOS完整App资源收集 <iOS完整app资源收集>  <GitHub 上有哪些完整的 iOS-App 源码值得参考?> <GitHub 上有哪些完整的 iOS-App ...

  9. 谈谈软件项目的dependency

    说到软件项目的依赖管理,可以从三个方面来考虑: 一.由build system控制的dependency 现在的build system,都支持一定程度上的dependency management, ...

随机推荐

  1. 表单验证之validform.js使用方法

    一.validform有什么用? 网页上有大量的input需要你进行验证的时候,如果是弹窗的话,需要不停地判断,如果为空,弹窗.如果不是数字,弹窗. 所以要将这么多验证交给一个js去验证. 二.我现在 ...

  2. Jenkins问题汇总

    1.在jenkins里使用shell,如果shell起子进程会被jenkins强制杀掉的解决方法. http://scmbob.org/start-process-in-jenkins.html

  3. 恢复windows 的快捷方式打开方法,亲测1-7恢复,

    相信有些用户曾试过错误地把LNK文件的打开方式更改其他文件,导致系统所有的快捷方式都失效.在vista与Windows7系统还不普遍使用的时候,相信大家会有点惊慌失措,不要紧,下面只要大家进行如下操作 ...

  4. 从日常开发说起,浅谈HTTP协议是做什么的。

    引言 HTTP协议作为Web开发的基础一直被大多数人所熟知,不过相信有很多人只知其一不知其二.比如咱们经常用到的session会话机制是如何实现的,可能很多人都说不出来吧.其实session会话就是H ...

  5. Git.Framework 框架随手记--存储过程简化

    在很多的ORM中对存储过程操作都是一个棘手的地方,因为存储过程是一段预编译的代码,其中可以包含很多处理过程.在Git.Framework中也同样存在这样的问题,目前没有能力解决这个问题.但是对于存储过 ...

  6. WebView与JavaScript的交互

    目录: 一.整体思路 二.简单例子实现过程        1.打开项目的asset目录,创建新的文件test.html        2.补充html代码:添加供本地调用的js方法.调用本地方法的js ...

  7. easyui中tree控件添加自定义图标icon

    来源于:http://blog.163.com/lintianhuanhai@126/blog/static/165587366201421704420256/ <!DOCTYPE html&g ...

  8. 第一个windows程序设计

    #include <windows.h> int WINAPI WinMain(HINSTANCE hinstabce, HINSTANCE prvhinstace, PSTR icmdL ...

  9. baidu时光轴_使用window.scroll实现的

    <!DOCTYPE html> <html> <head> <title></title> <meta charset="u ...

  10. hdu1507二分匹配

    1 //hdu1507 挺不错的题 #include<stdio.h> #include<string.h> #define INF 99999999 struct node ...