Tag: cllocationmanager

iBeacons:如果app在后台,locationManager:didEnterRegion:仅在locking屏幕显示时被调用

我正在为监视iBeacon地区的iOS应用程序工作。 当应用程序在后台运行时,我希望它在遇到特定的iBeacon区域时发送本地通知。 一切工作正常,除了一件事︰locationManager:didEnterRegion显然不会被调用,直到用户显示locking屏幕。 因此,即使设备在应用程序处于后台时通过iBeacon区域,它们也不会在显示locking屏幕之前收到通知。 我也尝试过使用startMonitoringForRegion,这种工作 – 如果应用程序在后台运行,locationManager:didDetermineState:当设备进入iBeacon区域时触发。 但是,它只会这样做 – 如果用户随后退出并重新进入iBeacon区域,则locationManager:didDetermineState不会再次触发。 我正在运行iPhone 5s,并使用iPhone 4s作为iBeacon,如果这有什么区别的话。 更正:这种现象显然只有当我使用iPhone 4s作为客户端时才会发生。 如果我使用5秒,则通知立即发送。

当用户退出区域时,删除已触发的基于位置的通知

我为我的应用程序设置了(默认iOS8)基于位置的通知。 UILocalNotification *notification = [[UILocalNotification alloc] init]; notification.regionTriggersOnce = NO; notification.userInfo = @{ @"notification_id" : @"someID" }; notification.region = region; notification.alertBody = alertBody; [[UIApplication sharedApplication] scheduleLocalNotification:notification]; 当用户进入指定区域时, NotificationCenter正确显示在NotificationCenter 。 但是,我想在用户退出该区域时删除该通知消息,因为用户无法回家查看通知中心,直到他们收到如下所示的消息: “你在XXXXX!” 有没有人试过类似的东西? 文件不清楚如何做到这一点。

在哪个iOS设备上完全支持区域监视?

从我可以从苹果示例区域监控代码的运行时需求中解释,区域监控可用于iPhone 4,iPad 2 Wifi + 3G或更高版本。 所以我假设它不适用于3G或iPhone 3G / 3GS的iPad1。 这是一个正确的解释? 我不能testing这个,因为我没有所有这些设备,我找不到这个官方文档。 PS:我知道我可以通过调用regionMonitoringAvailable方法在代码中检查它,但是我需要这些信息来决定我的应用程序的体系结构,所以我需要知道这一点。

位置更新在后台和暂停的应用程序模式

我想写的应用程序,每5分钟发送到服务器的低精度位置为它的两种模式:前景和背景。 因为我不想减less电池充电,并且位置信号变化只给出高精度值,所以我每5分钟就从GPS开始/停止位置更新。 应用程序从前台模式工作正常,但从后台模式只工作约1小时(并停止发送位置后)。 我想我在backgroundTask / NSTimer代码丢失的东西,因为我是新的iOS。 我会非常感谢你的帮助。 该应用程序将只适用于iOS 7及以上。 一般来说,我的algorithm如下: ** start backGroundTask ** [_locationManager startUpdatingLocation] ** handle received location in "didUpdateLocations:" listener ** [_locationManager stopUpdatingLocation] ** create new thread and fire the NSTimer with delay 5 min ** end backGroundTask 这是我的代码: – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [self startLocationManager]; // .. other init app […]

计算两个向量之间的angular度?

我正在开发一个iOS应用程序,它必须根据设备标题显示兴趣点(兴趣点)。 我使用CLLocationManager来获取用户的位置和标题。 我有一对目的地的坐标。 基于此,我正在计算哪一个季度是这样的,并返回偏离南(0度)的浮点值。 我在北方有180度,南方有0度。 这里是代码片段: -(float)updateTargetLongitude:(float)lon Latitude:(float)lat{ // //longitude = x // //latitude = y NSLog(@"current location = (%.5f, %.5f)", [[NSUserDefaults standardUserDefaults] doubleForKey:@"currentLongitude"], [[NSUserDefaults standardUserDefaults] doubleForKey:@"currentLatitude"]); float x = lon – [[NSUserDefaults standardUserDefaults] doubleForKey:@"currentLongitude"]; float y = lat – [[NSUserDefaults standardUserDefaults] doubleForKey:@"currentLatitude"]; float angle; NSLog(@"Searching angle from source (%.5f, %.5f) to destination (%.5f, %.5f)", […]

不在背景上调用CLLocationManager委托方法

我正在构build一个应用程序,检查用户是否在我的客户的商店附近,如果有,它会向他发送一个通知。 我希望应用程序在后台检查它。 我已经将这行添加到我的info.plist文件中: 图片 这里是我的代码: AppDelegate.m : -(BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [self configureLocationManager]; [self.locationManager startUpdatingLocation]; return YES; } -(void)configureLocationManager { //Initializing locationManager self.locationManager=[[CLLocationManager alloc] init]; //setting "locationManager"'s(CLLocationManager) delegate to "self" self.locationManager.delegate=self.monitorLocationVC; //Setting "locationManager"'s(CLLocationManager)'s distance filter to none //self.locationManager.distanceFilter=kCLDistanceFilterNone; //Setting "locationManager"'s(CLLocationManager)'s activityType to navigation self.locationManager.activityType=CLActivityTypeAutomotiveNavigation; //setting "locationManager"'s(CLLocationManager) desiredAccuracy to "best" self.locationManager.desiredAccuracy=kCLLocationAccuracyBestForNavigation; //If OS version is […]

用于位置更新多个视图的单身人士

我想在任何视图中按下导航栏中的定位button之后,在所有视图中更新用户位置。 我已经开始创build一个单身人士。 Location.h #import <Foundation/Foundation.h> #import <CoreLocation/CoreLocation.h> #import <MapKit/MapKit.h> @interface Location : NSObject <CLLocationManagerDelegate> @property (nonatomic, strong) CLLocationManager* locationManager; + (Location*)sharedSingleton; @end Location.m #import "Location.h" @implementation Location { CLLocationManager *locationManager; CLGeocoder *geocoder; CLPlacemark *placemark; } @synthesize locationManager; – (id)init { self = [super init]; if(self) { self.locationManager = [CLLocationManager new]; [self.locationManager setDelegate:self]; [self.locationManager setDistanceFilter:kCLDistanceFilterNone]; [self.locationManager […]

标准位置服务在后台运行的iOS 4应用程序生命周期行为

我正在开发一个位置跟踪应用程序,该应用程序在后台同时使用标准位置服务和重要更改位置服务(我的应用程序已注册iOS 4或更高版本中的后台位置更新)。 感谢这个问题,我对于从后台状态返回的重大变化以及从终止状态重新启动有了很好的理解。 但是,我仍然不清楚标准位置服务在这些情况下的行为。 任何人都可以打破在后台运行的标准位置服务的确切行为? 特别: 标准位置服务在离开运行时应如何运行,应用程序是否挂起到后台? 从我自己的testing中,我已经看到,它将继续醒来接收locationManager:didUpdateToLocation:fromLocation:callbacklocationManager:didUpdateToLocation:fromLocation:我有它发送一个套接字的位置,我可以看到它在networking上)。 这个callback是否有时间限制或内存限制? 即使我的应用程序终止,标准位置服务是否继续运行? 也就是说,它会重新启动与application:didFinishLaunchingWithOptions:与UIApplicationLaunchOptionsLocationKey重要更改服务的方式? 我认为在这种情况下, CLLocationManager也需要重新启动,就像重要更改服务一样。 谢谢。

错误:从不兼容的types“id”分配给“CLLocationCoordinate2D”

海我试图在mkmap中显示多个注释。 当我添加坐标时,它显示错误:“从不兼容的types”id“”分配给“CLLocationCoordinate2D”。 我知道这是一个简单的概率,但我已经search了很多次,并尝试了很多,但没有工作,我的代码是, for(int i=0 ; i<coordinates.count ; i++) { MKPointAnnotation *point = [[MKPointAnnotation alloc] init]; point.coordinate =[coordinates objectAtIndex:i]; //here it shows the error point.title = @"title"; [self.mapView addAnnotation:point]; } 善意地build议我解决这个问题。 谢谢…

即使手机在swift中重新启动后,如何在后台获取位置?

我正在开发一个应用程序跟踪用户select的时间间隔的电话位置。 我用定时器启动了startUpdatingLocation ,当它得到位置停止更新时,将位置发送到服务器并再次启动定时器。 一切都在后台完成。 即使手机重新启动并将数据发送到服务器,我也需要在后台模式(iOS 8中)中获取位置数据。 我尝试了数百种方法,没有人为我工作。 所以…我现在得到了什么:在info.plist: 所需的背景模式 – 位置和获取 NSLocationAlwaysUsageDescription – 位置是需要此应用程序正常工作 在AppDelegate中: var locationController: LocationController = LocationController() as LocationController; func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool { UIApplication.sharedApplication().setMinimumBackgroundFetchInterval(UIApplicationBackgroundFetchIntervalMinimum); var bgTask = UIBackgroundTaskIdentifier() bgTask = UIApplication.sharedApplication().beginBackgroundTaskWithExpirationHandler { () -> Void in UIApplication.sharedApplication().endBackgroundTask(bgTask) } if(self.locationController.profileForTracking != nil && self.locationController.profileForTracking != "Disabled" && self.locationController.intervalForTracking […]