Tag: core location

当应用程序被杀时如何获得准确的位置更新?

我正在开发一个基于位置的应用程序,在这个应用程序中,用户可以存储多个位置,当用户靠近存储位置时,应用程序将通过本地通知通知用户。 我用下面的代码来实现这个function: -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { if([[UIApplication sharedApplication] backgroundRefreshStatus] == UIBackgroundRefreshStatusDenied){ [self showAlertWithTitle:@"" andMessage:@"The app doesn't work without the Background App Refresh enabled. To turn it on, go to Settings > General > Background App Refresh."]; }else if([[UIApplication sharedApplication] backgroundRefreshStatus] == UIBackgroundRefreshStatusRestricted){ [self showAlertWithTitle:@"" andMessage:@"The functions of this app are limited because the Background […]

在Geo-Fencing中多次调用区域监控方法

我创build了多个地理围栏来监视区域进入/退出事件。 我在AppDelegate.h文件中创build了一个位置pipe理器 。 @interface AppDelegate : UIResponder <UIApplicationDelegate, CLLocationManagerDelegate> @property (strong, nonatomic) UIWindow *window; @property(nonatomic,retain)CLLocationManager *locationManager; @property(nonatomic,retain)CLLocation *currentLocation; +(AppDelegate *)sharedDelegate; AppDelegate.m文件 – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; if (notification) { NSLog(@"AppDelegate didFinishLaunchingWithOptions"); application.applicationIconBadgeNumber = 0; } if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) { UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge|UIUserNotificationTypeAlert|UIUserNotificationTypeSound) categories:nil]; [application registerUserNotificationSettings:settings]; } else […]

CLLocationManager startMonitoringForRegion:设备重启后不重新启动应用程序

好的,所以我现在有一个应用程序,我使用CLLocationManager startMonitoringForRegion方法注册一个地理栅栏来监视。 这个应用程序在前台和后台时正常工作。 我也有适当的plist值设置: UIBackgroundModes :{location} UIRequiredDeviceCapabilities: {location-services} 什么都行不通 设备重新启动后,应用程序不会重新启动。 如果在进入后台之前设置了startMonitoringSignificantLocationChanges ,我可以强制执行此操作。 但这种方法使用更多的电池寿命,我不需要所有的时间,只要我打破地理围栏。 地区的文档说: In iOS, the regions you register with the location manager persist between launches of your application. If a region crossing occurs while your iOS app is not running, the system automatically wakes it up (or relaunches it) in the background so […]

CLLocationManager坐标

我一直在努力实施步行,骑自行车和驾驶的路线图。 但是,正如你在下面的屏幕截图中所看到的那样,即使我没有走路/骑自行车或者驾驶那个位置,我的坐标也会不时跳跃。 这个圆圈已经画在图像上来指出这个问题。 我的问题是为什么所有的突然坐标跳转? 这是我的实现快照: – (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { CoordinateModel *coord = [[CoordinateModel alloc] init]; coord.latitude = newLocation.coordinate.latitude; coord.longitude = newLocation.coordinate.longitude; ActivityType currentActivityType = [DataManager sharedInstance].activityType; if (currentActivityType == 0) { // walking [appDelegate.walkingCoordinates addObject:coord]; } else if(currentActivityType == 1) { [appDelegate.bikingCoordinates addObject:coord]; } else if(currentActivityType == 2) { // driving […]

弃用的CLRegion方法 – 如何获得半径?

我使用geocodeAddressString:completionHandler:方法,它返回一个CLPlacemarks数组。 我必须得到纬度,经度,记忆名称和半径。 获得前3个很容易: double lat = placemark.location.coordinate.latitude; double lng = placemark.location.coordinate.longitude; NSString *name = [NSString stringWithFormat:@"%@", ABCreateStringWithAddressDictionary(placemark.addressDictionary, NO)] 我不知道如何获得半径现在,因为placemark.region.radius已被弃用。 任何想法现在使用什么呢? 在文档中我找不到任何有趣的东西。

与核心位置pipe理器对象一起使用时,initWithCoder实际上在做什么?

好的,我想用initWithCoder完全理解这段代码。 在阅读了几篇build议的文档并阅读了一本关于授权,核心位置,指定初始化程序的书的章节之后,我想这就是我想要做的。 使用指向NSCoder对象的指针初始化我的viewcontroler。 如果这个工作,然后创build一个位置pipe理器对象的实例 使委托我的viewcontroller。 将位置精度设置为最佳。 告诉位置pipe理员开始更新。 将存储在委托中的信息logging到控制台。 lat和long存储在一个作为parameter passing给locationManager:DidUpdateLocations:方法的NSArray对象的指针中。 如果没有find位置,请在控制台中logging此状态。 .h接口文件: #import <UIKit/UIKit.h> #import <CoreLocation/CoreLocation.h> @interface WhereamiViewController : UIViewController { CLLocationManager *locationManager; } @end .m执行文件: #import "WhereamiViewController.h" @interface WhereamiViewController () @end @implementation WhereamiViewController – (id)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; if (self){ //create location manager object locationManager = [[CLLocationManager alloc] init]; //there will […]

ios会在特定时间后终止在后台运行的应用程序吗?

我在我的应用程序中使用核心位置框架,我设置位置string在UIBackgroundMode或所需的背景模式(在Xcode 4.2中),以获取更新的位置从didUpdateToLocation方法,当应用程序在后台运行,也通过点击发送这个更新的位置服务器核心位置框架的didUpdateToLocation方法内的具体链接。 我的问题是,在后台运行一段时间后,应用程序将被终止?

重大的位置变化至less不会每15分钟触发一次

根据苹果文档,重要的位置变化应该至less每15分钟更新位置。 当我明显移动时,确实会收到更新,但在设备静止时不会收到更新。 你有什么更新的经验? 他们至less每15分钟来一次吗? 如果GPS级精度对您的应用程序不是至关重要的,并且您不需要连续跟踪,则可以使用重大更改位置服务。 正确使用重大更改位置服务至关重要,因为它至less每隔15分钟就会唤醒系统和应用程序,即使没有发生位置更改,也会持续运行,直到您停止。

从CLLocation数组中创buildGPX文件

我的应用程序需要使用应用程序共享设备内的CLLocations(Route)数组。我之前没有使用过GPX的经验。 GPX是最好的格式吗? 我如何从给定的CLLocations数组创buildGPX文件? 目标C中是否有标准的GPXparsing器? 从我在网上search和所以这些问题的答案分别是 1.cant say 2. I have seen some webpages converting data of points in GPX format but could not find how they are doing it. 3. No 我会很高兴,如果我得到替代答案/意见。 我明白这是很多问题。 任何帮助或build议将非常感激。

iOS从后台重新检查加载位置

我正在构build一个应用程序,根据您当前的位置显示结果数据。 目前,我使用UIViewController的viewDidLoad方法来启动CLLocationManager并获取当前位置。 一旦我的位置符合我所希望的准确性,我会向我的Web服务请求获取结果并将其转储到UITableView 。 我的问题是,当你closures应用程序(尽pipe它仍然在后台运行)。 如果您要开车到另一个城镇,请重新打开应用程序,数据不会更新,并继续显示旧位置的结果。 基本上,当UIViewController从后台加载,我需要能够检查用户的位置,如果他们已经移动了很长的距离,更新我的UITableView的内容。 但是,因为UIViewController的viewDidAppear没有被触发,当你从后台加载应用程序,我不知道我可以使用哪种方法。 我知道stopMonitoringSignificantLocationChanges方法,它会在find新的位置时唤醒您的应用程序。 不过,这似乎有点OTT,因为我只需要知道应用程序加载。 有没有其他select使用stopMonitoringSignificantLocationChanges方法?