【发布时间】:2016-03-28 05:42:36
【问题描述】:
我有一个应用程序可以检查用户是否接近我客户的一家商店,当他接近时,该应用程序会向他发送通知,告诉他他在商店附近。
当然,我正在使用地理围栏 (locationManager: didEnterRegion),我有 20 多家商店,所以locationManager: didUpdateLocations 我正在对离用户最近的 20 家商店进行排序。
我在AppDelegate 上以这种方式配置我的CLLocationManager,然后将我的ViewController locationManager 属性设置为对象(因为我也想在AppDelegate 上使用相同的locationManager :
-(void)configureLocationManager
{
//Initializing "locationManager"'s(CLLocationManager)
self.locationManager=[[CLLocationManager alloc] init];
//Setting "locationManager"'s(CLLocationManager)'s delegate to "monitorLocationVC"(monitorLocationViewController)
self.locationManager.delegate=self.monitorLocationVC;
//Setting "locationManager"'s(CLLocationManager)'s distance filter to 10
self.locationManager.distanceFilter=10;
//Setting "locationManager"'s(CLLocationManager)'s activityType to navigation
self.locationManager.activityType=CLActivityTypeAutomotiveNavigation;
//setting "locationManager"'s(CLLocationManager) desiredAccuracy to "best"
self.locationManager.desiredAccuracy=kCLLocationAccuracyBest;
//Setting "locationManager"'s(CLLocationManager)'s pausesLocationUpdatesAutomatically to NO
self.locationManager.pausesLocationUpdatesAutomatically=NO;
//If OS version is 9 or above - setting "allowsBackgroundLocationUpdates" to YES
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9) {
self.locationManager.allowsBackgroundLocationUpdates = YES;
}
}
到目前为止一切正常,但现在我看到该应用在运行几分钟后开始不通知后台商店(通知大约 15 分钟,然后突然停止)。
注意:有时当我从主屏幕启动我的应用程序(只是正常启动)时,应用程序会崩溃,这可能是问题所在吗?
谢谢!
【问题讨论】:
-
@kb920 到现在为止,该应用程序运行良好,所以代码是正确的,我只是在寻找使应用程序停止监视重大位置变化的错误
-
什么是崩溃日志?
-
@kb920 我真的不知道,因为我的 iPhone 在未连接到 Xcode 时会崩溃
-
@FS.O 您可以将crashlytics.com 或mint.splunk.com 添加到您的项目中,以实时从设备获取崩溃日志。或者在 iPhone 设置诊断中检查设备崩溃日志
标签: ios objective-c iphone cocoa-touch cllocationmanager