繁体   English   中英

在不使用位置服务IOS的情况下获取后台位置

[英]Getting Background Location Without using location services IOS

我的应用遭到拒绝,因为

我们发现您的应用使用后台模式,但不包含要求该模式持续运行的功能。 此行为不符合《 App Store审查指南》。

我们注意到您的应用在Info.plist的UIBackgroundModes项中声明了对位置的支持,但其中不包含需要永久位置的功能。

我需要在后台跟踪用户位置,以便在用户靠近应用程序上他/她的图片之一时发出通知。 这就是为什么我在.plist上使用背景模式键的原因

这是我如何初始化我的locationManager

_locationManager = [[CLLocationManager alloc] init];
_locationManager.delegate = self;
_locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
_locationManager.distanceFilter = 1000; // Will update evert 1 KM.
_locationManager.activityType = CLActivityTypeFitness;
_locationManager.pausesLocationUpdatesAutomatically = YES;
[_locationManager startUpdatingLocation];

我正在使用didUpdateToLocation来接收背景位置。

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
    if (_currentLocation == nil){
        self.currentLocation = newLocation;
    }else{

        if([self.currentLocation distanceFromLocation:newLocation]){
            [self getNearPicturesMethod:newLocation];
        }
    }

}

他们向我指出,我应该使用“ startMonitoringSignificantLocationChanges”,但如果我删除了背景键(他们想要的),则该应用程序即使在前台也不会再收到位置更新,它们仅在用户打开它时才显示不为我工作。

PS。 我阅读了相关的问题,但似乎没有人解决此问题或提供解决方法。

您的应用会在位置发生重大变化时唤醒。 您不需要为此设置背景位置模式键。 区域边界监视也是如此。

对于您的情况,我认为您更可能希望为最近的图片设置区域,然后仅等待越过边界。

使用重要的位置更改来更新最近的图片,并将您的地区重置为这些图片。

这将按预期工作,并且符合Apple文档的规定,并且对用户电池的影响很小(如果有的话)。

暂无
暂无

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

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