cllocationmanager

Remove fired Location-Based notification when user exits region

℡╲_俬逩灬. 提交于 2019-12-22 03:30:27
问题 I've setup (default iOS8) location-based notifications for my app. UILocalNotification *notification = [[UILocalNotification alloc] init]; notification.regionTriggersOnce = NO; notification.userInfo = @{ @"notification_id" : @"someID" }; notification.region = region; notification.alertBody = alertBody; [[UIApplication sharedApplication] scheduleLocalNotification:notification]; When a user enters the specified region, the notification is shown in the NotificationCenter correctly. However, I

iOS App Background Location (Push Notifications)

痞子三分冷 提交于 2019-12-22 01:16:49
问题 I face an issue where my app requires the users location when they receive a push notification while the app is running in the background. After doing a bit of reading I'm under the impression that this isn't possible, i.e: 1) App in background 2) Push notification received 3) Get users location and execute block of code. I found this post on here that suggests you can run a task every N amount of minutes to get the users location. So using this I could check say every ten minutes which would

Error : Assigning to 'CLLocationCoordinate2D' from incompatible type 'id'

不羁岁月 提交于 2019-12-21 21:13:10
问题 Hai I am trying to display multiple annotations in mkmap. While am adding the coordinates it shows the error:"Assigning to 'CLLocationCoordinate2D' from incompatible type 'id'". I know this is a simple prob, but I have searched many times and tried a lot but none works, my code is, 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

how to trap the location alert response iphone

雨燕双飞 提交于 2019-12-21 20:38:54
问题 I am using GPS in iphone and it show conformation message for use location service. and i want to trap what user select "Allow" or "No". can any one suggest how i do this? Thank 回答1: You don't get a direct callback from this alert. However, if the user does not allow Core Location usage, you'll receive a -locationManager:didFailWithError: with a kCLErrorDenied error to your CLLocationManagerDelegate . Since iOS 4.2, you can also listen to -locationManager:didChangeAuthorizationStatus: or

How to ask permission from user for second time to allow to access the current location?

浪子不回头ぞ 提交于 2019-12-21 18:36:14
问题 In my app, if the user not allowed to access their current location, I can recieve that message in the following method - (void)locationManager:(CLLocationManager*)aManager didFailWithError:(NSError*)anError { switch([anError code]) { case kCLErrorLocationUnknown: break; case kCLErrorDenied: { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Access Denied" message:@"You didn't allow to access your current location" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [alert

iOS Waiting for Location Manager to Init

感情迁移 提交于 2019-12-21 12:17:40
问题 I'm developing an iOS app based on the map and location tracking. When the user first boots the app it asks for permission to track location etc. just fine. The only problem is while it's doing that, I have code setting up the initial map view and other location-based variables before the user has clicked OK. I've found I can put these initiation steps after a while loop that waits for the user to change the location manager's permissions as below but this can't possibly be best practice, not

iOS Geofence, how to handle when inside region when monitoring starts?

五迷三道 提交于 2019-12-21 09:21:58
问题 I have been unable to work out how to handle a scenario where the phone is already inside a region when startMonitoringForRegion is called? Other questions have suggested calling requestStateForRegion inside didStartMonitoringForRegion this then calls the method didDetermineState: forRegion: . So the code looks something like this: - (void)viewDidLoad { //location manager set up etc... for (Object *object in allObjects){ CLRegion *region = [self geofenceRegion:object]; [locationManager

CLLocationManager.authorizationStatus() always CLAuthorizationStatus.NotDetermined with swift&objC app

折月煮酒 提交于 2019-12-21 07:07:03
问题 I just can get my CLLocationManager to authorise. (swift under ios8) I even add an explicit requestAlwaysAuthorization call (which I don't need with objC under ios7) func finishLaunch() { //ask for authorization let status = CLLocationManager.authorizationStatus() if(status == CLAuthorizationStatus.NotDetermined) { self.locationManager.requestAlwaysAuthorization(); } else { self.startMonitoring() } ... } the callback never gets anything but NotDermined and there is no UIAlertView shown to the

How do startMonitoringSignificantLocationChanges and startUpdatingLocation effect one-another?

ぐ巨炮叔叔 提交于 2019-12-21 07:02:51
问题 What happens if I call startUpdatingLocation while startMonitoringSignificantLocationChanges is running? Does significantLocationChange monitoring get stopped? If I then stopUpdatingLocation will significantLocationChange monitoring continue or restart? I can find no documentation covering the interplay between these two ways of monitoring location. 回答1: They are not meant to be used concurrently. It's either or as they both deliver heading and location changes to the same delegate method.

iOS CoreLocation checking CLLocation timestamp to use it

回眸只為那壹抹淺笑 提交于 2019-12-21 05:51:46
问题 How do you check a CLLocation object and decide whether you want to use it or discard the result and get a new location update instead? I saw the timestamp property on CLLocation, but I'm not sure how to compare that to the current time. Also, after I do compare the time and find the difference in seconds, what value should the difference be under for me to use that CLLocation object? What's a good threshold. Thanks! 回答1: Is really important to check the timestamp, because iOS usually caches