Note that there are some explanatory texts on larger screens.

plurals
  1. POStartUpdateLocation during a didreceiveremotenotification:fetch
    primarykey
    data
    text
    <p>Good evening everyone !</p> <p>I have a simple question : How to enable [CLLocationManager startUpdateLocation] when I receive a correct push notification using didReceiveRemoteNotification:fetch on iOS 7 ?</p> <p>Right now, I have : </p> <pre><code>- (void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { if ([userInfo objectForKey:@"aps"] &amp;&amp; [[userInfo objectForKey:@"aps"] objectForKey:@"content-available"]) { if ([userInfo objectForKey:@"update-location"]) { [self performSelectorInBackground:@selector(handleLocationNotificationPush:) withObject:completionHandler]; } if ([userInfo objectForKey:@"update-sensors"]) { } } } -(void)handleLocationNotificationPush:(void (^)(UIBackgroundFetchResult))completionHandler { [CLController.locMgr startUpdatingLocation]; ++nbPushReceive; [self.pushLockForLocation lock]; if ([self.pushLockForLocation waitUntilDate:[NSDate dateWithTimeIntervalSinceNow:25]] == TRUE &amp;&amp; self.lastKnownLocation != nil) { [self.pushLockForLocation unlock]; // Send my new location to server using HTTP request [self sendLocationForPushUpdates:self.lastKnownLocation fetchCompletionHandler:completionHandler]; if (![UIApplication sharedApplication].applicationState == UIApplicationStateActive) // it stops location updates [self stopAllLocationUpdates]; return; } // In case we didn't receive any new position during 25 secondes [self.pushLockForLocation unlock]; if (![UIApplication sharedApplication].applicationState == UIApplicationStateActive) { [self stopAllLocationUpdates]; } completionHandler(UIBackgroundFetchResultNoData); } - (void)locationUpdate:(CLLocation *)location { NSLog(@" *** LocationContrller - LocationUpdate location"); self.lastKnownLocation = location; if (location.horizontalAccuracy &lt; 500) { [self.pushLockForLocation signal]; } } </code></pre> <p>Of course, my CLController delegate is the same class (location updates work when application is in foreground). In my plist.file, I have the "Remote notifications" checked. </p> <p>I am missing something ?</p> <p>Thanks for your help ! :D</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload