I have an application which register itself for Significant Location Changed Services
when it goes to background.
As per docs reading over the net and my understanding, I have written following code in
didFinishLaunchingWithOptions method and I was expecting when app is launches in background and
launched with core location event then it should return and should not create any user interface:
when it goes to background.
As per docs reading over the net and my understanding, I have written following code in
didFinishLaunchingWithOptions method and I was expecting when app is launches in background and
launched with core location event then it should return and should not create any user interface:
Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
id locationValue = [launchOptions objectForKey:UIApplicationLaunchOptionsLocationKey];
/*
[COLOR="Red"]
If I normally launch the app by pressing its icon from home screen, then application goes in this if block,
strange !! it should not do like this because app is not launched by Core Location Event and also not in
background.
Side effect of this on my app is that, because app is going in if block it immediately returns and shows
BLACK SCREEN because it could not able to show view that is added to window.
[/COLOR]
*/
if (locationValue && [UIApplication sharedApplication].applicationState == UIApplicationStateBackground)
{
#ifdef DEBUG
LogToFile(@" App was launched in response to a CoreLocation event. ");
[Helper showAlertViewWithTitle: @"Significant Location"
message: @"App was launched in response to a CoreLocation event."
delegate: nil
buttonTitles: [NSArray arrayWithObject: @"OK"]
cancelButtonIndex: 0];
#endif
singnificantLocationManager = [[CLLocationManager alloc] init];
singnificantLocationManager.delegate = self;
[singnificantLocationManager startMonitoringSignificantLocationChanges];
return YES;
}
// adding view to window
navigationController = [NavigationController sharedNavigationController];
[window addSubview:navigationController.view];
[self.window makeKeyAndVisible];
return YES;
}
Last edited: