ios8 - CloudKit Push Notification, App running on background -


when ios8.2-app running in background, not receive push notification,

while if running on foreground, receives push notifications fine.

any idea going on ?

running on cloudkit development mode, subscription add,edit,and remove, , using following didreceiveremotenotification:

-(void)application:(uiapplication *)application didreceiveremotenotification:(nsdictionary *)userinfo fetchcompletionhandler:(void (^)(uibackgroundfetchresult))completionhandler {     nslog(@"push received.");      nsdictionary * apsdict = [userinfo objectforkey:@"aps"];      nsstring * alerttext = [apsdict objectforkey:@"alert"];      //todo: record information notification , create appropriate message string.      if(application.applicationstate == uiapplicationstateactive) {         uialertview * alert = [[uialertview alloc] initwithtitle:@"notification" message:alerttext delegate:nil cancelbuttontitle:@"ok" otherbuttontitles: nil];         [alert show];     } else {          if([application currentusernotificationsettings].types & uiusernotificationtypealert) {             uilocalnotification * localnotification = [[uilocalnotification alloc] init];             localnotification.alertbody = nslocalizedstring(@"alert body", nil);;             localnotification.firedate = [nsdate datewithtimeintervalsincenow:2];             [application presentlocalnotificationnow:localnotification];         }     }      completionhandler(uibackgroundfetchresultnodata); } 

when go app settings capabilities, have remote notifications enabled background modes?

see screenshot: enter image description here

besides that, did register notification types this:

application.registerusernotificationsettings(uiusernotificationsettings(fortypes: .alert | .badge | .sound, categories: nil))     application.registerforremotenotifications() 

and in subscription, send alertbody or alertlocalizationkey cknotificationinfo? if that, notification os , don't need setup local notification.

update: porton mentioned below, issue solved filling in alertbody.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -