2013-08-09 1 views

답변

2

// 응용 프로그램이 활성 상태에서 비활성 상태로 곧바로 이동할 때.

- (void)applicationWillResignActive:(UIApplication *)application 
{ 
    [self sendBackgroundLocationToServer]; 
} 


- (void) sendBackgroundLocationToServer 
{ 
UIBackgroundTaskIdentifier bgTask = UIBackgroundTaskInvalid; 
bgTask = [[UIApplication sharedApplication] 
      beginBackgroundTaskWithExpirationHandler:^{ 
       [[UIApplication sharedApplication] endBackgroundTask:bgTask]; 
      }]; 


//Start Timer 
[self startTimer]; 

//Close the task 
if (bgTask != UIBackgroundTaskInvalid) 
{ 
    [[UIApplication sharedApplication] endBackgroundTask:bgTask]; 
} 
} 
+0

감사합니다. –

관련 문제