简体   繁体   English

位置更新无法在iPhone4s和iPhone5的后台模式下的iOS 7.0中运行,而iPhone处于理想状态

[英]Location update not working in background mode iOS 7.0 in iPhone4s and iPhone5 while iPhone in ideal

i am working on one tracking application in that i use location manager service and 我正在使用一个位置管理器服务来开发一个跟踪应用程序,

set desiredAccuracy = kCLLocationAccuracyNearestTenMeters 设置期望的精度= kCLLocationAccuracyNearestTenMeters

and distanceFilter = 60.0. 而distanceFilter = 60.0。

i want to give background support. 我想提供背景支持。 for that i 为此我

set App registers for location updates, 设置应用注册以进行位置更新,

App downloads content from the network 应用程序从网络下载内容

in my info.plist. 在我的info.plist中。 and i put 我把

[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum];

this code in didFinishLaunchingWithOptions method. 此代码在didFinishLaunchingWithOptions方法中。

i also use this method for call startUpdatingLocation location manager method 我也使用此方法来调用startUpdatingLocation位置管理器方法

- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler

this all work in iOS 7 with iPhone4 这一切都可以在iPhone 7的iOS 7中使用

but i have other two device in iPhone4S and iPhone5 in that device when device is ideal at that time application is in background so the navigation symbol get disappear and my location data not get updated on server. 但是我当时在设备中处于理想状态时,该设备在iPhone4S和iPhone5中还有另外两个设备,因此导航符号消失了,服务器上的位置数据也没有更新。

when phone is ideal and when i start my application its not in background my application start from login screen. 当电话是理想的,当我启动我的应用程序时,它不是在后台运行,而是从登录屏幕启动。

so background location update not work for iPhone5 and iPhone4S having iOS7. 因此后台位置更新不适用于具有iOS7的iPhone5和iPhone4S。

Please provide me solution for this. 请为此提供解决方案。

my application is for tracking purpose if i am not get updated location so it is useless. 如果我没有获得更新的位置,我的应用程序将用于跟踪,因此它没有用。

you can add this methods in your AppDelegate.m 您可以在AppDelegate.m中添加此方法

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
        NSLog(@"ending background task");
        [[UIApplication sharedApplication] endBackgroundTask:bgTask];
        bgTask = UIBackgroundTaskInvalid;
    }];

    timer = [NSTimer scheduledTimerWithTimeInterval:5
      target:locationManager
      selector:@selector(startUpdatingLocation)
      userInfo:nil
      repeats:YES
    ];
}

you can take help with below link: Start Location Manager in iOS 7 from background task 您可以通过以下链接获取帮助: 从后台任务启动iOS 7中的位置管理器

to get your location update at interval of every 5 minutes. 每隔5分钟更新一次您的位置信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM