2016-10-01 1 views
0
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler 

Elle est appelée avec content-available = 1. Une tâche de téléchargement démarre (affiche le NSLogs), mais elle n'achève pas la tâche appelée. Ce n'est que lors du changement de l'application au premier plan, il finit la tâche appelée précédente.L'application effectue une tâche en arrière-plan (après avoir reçu une notification à distance), mais ne termine pas complètement

Une idée ... comment cela peut-il arriver?

+0

clarifier votre i na pas eu ques ..? – vaibhav

+0

vous voulez dire que votre API ne répond pas en arrière-plan? –

+0

Lorsque l'application est en arrière-plan et qu'une notification push à distance arrive, une tâche Parse "getObjectsInBackGround" est appelée. Cette tâche ne se termine pas lorsque l'application est en arrière-plan, mais elle continue après la transition vers l'avant-plan. – JeeGee

Répondre

0

Vous devez utiliser UIBackgroundTaskIdentifier.pour effectuer un appel api en arrière-plan.

 - (void)applicationDidEnterBackground:(UIApplication *)application { 




     isnotificationScreenopen = NO; 
     UIBackgroundTaskIdentifier bgTaskId =[[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{ 
      [[UIApplication sharedApplication] endBackgroundTask:bgTaskId]; 
      NSLog(@"%f",[UIApplication sharedApplication].backgroundTimeRemaining); 
     }]; 
     NSLog(@"%f",[UIApplication sharedApplication].backgroundTimeRemaining); 



} 

vous pouvez aussi lire ce lien aussi

objective c - Proper use of beginBackgroundTaskWithExpirationHandler