ios - Push notification showing before background refresh finished (using Push with background refresh) -


i trying set app when push received first fetches new messages before showing push notification. in push notification have content-available = 1 set , switches enabled in plist. have implemented:

- (void)application:(uiapplication *)application didreceiveremotenotification:(nsdictionary *)userinfo fetchcompletionhandler:(void (^)(uibackgroundfetchresult result))handler {      if([[userinfo objectforkey:@"aps"] objectforkey:@"content-available"]){          nslog(@"doing background refresh");         uinavigationcontroller *navigationcontroller=(uinavigationcontroller *)[[[uiapplication sharedapplication] keywindow] rootviewcontroller];          myviewcontroller *myviewcontroller = (myviewcontroller *)[[navigationcontroller viewcontrollers] objectatindex:1];          [myviewcontroller.currentuser refreshmessagesarraywithcompletionhandler:^(bool successful, bool newmiaos) {              nslog(@"messages refreshed array has %lu messages",(unsigned long)[myviewcontroller.currentuser.messages count]);             handler(uibackgroundfetchresultnewdata);          }];         } } 

the app push come in before background finish has finished or during refresh. surely should come in after. dealing wrong? need send silent push notification instead , show local notification after completion block?

i had issue similar yours,
resolved it, sending push notification this

{         "alert": null,         "content-available": 1,         "data-id" : "some_data_id" } 

in case push notification not displayed, in background fetch can perform fetching , trigger local notification.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -