2013-11-27 2 views
3

이 방법 (application:didReceiveRemoteNotification:fetchCompletionHandler:)을 수행하면 completionHandler에있는 블록을 호출하는 방법이 있습니까?완료 핸들러가 호출되지 않았습니까?

문서에 "실제로는 필요한 데이터를 다운로드 한 후 가능한 빨리 처리기 블록을 호출해야합니다."라는 설명이 있습니다. 예를 들어

+1

@Kay 넬슨, 도와 주셔서 감사합니다. – Roby

답변

6

:

- (void)application:(UIApplication *)application 
didReceiveRemoteNotification:(NSDictionary *)userInfo 
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler 
{ 
    // Based on the provided meta data in userInfo, load the resource from our 
    // server which corresponds to the "updated" information: 

    NSDictionary* params = ; // based on userInfo 
    [self fetchInfoWithParams:params completion:^(NSData* result, NSError* error){ 
     UIBackgroundFetchResult fetchResult; 
     if (error) { 
      fetchResult = UIBackgroundFetchResultFailed; 
     } 
     else if (result) { 
      fetchResult = UIBackgroundFetchResultNewData; 
     } 
     else { 
      // data is nil 
      fetchResult = UIBackgroundFetchResultNoData; 
     } 

     // call the handler (if any): 
     if (handler) { 
      handler(fetchResult); 
     } 
    }]; 
} 
+0

, 괜찮습니다! 고맙습니다. – Roby

+0

좋은, 내 문제를 해결하십시오. –

관련 문제