Q: Push notification does not appear in notification centre when the app is in background iOS app
I have in my application notification comes both in foreground and in background but what happens it's not appearing in notification centre when the app is in background mode.-(void)registerAppForPushNotification{
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert |UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
- (void)applicationUIApplication *)application didReceiveRemoteNotificationNSDictionary *)userInfo {
NSLog(@"userInfo description %@",[userInfo description]);
}
- (BOOL)applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)launchOptions
{
#if TARGET_IPHONE_SIMULATOR
NSLog(@"Running in Simulator - no app store or giro");
#else
[self registerAppForPushNotification];
#endif
if (launchOptions) { //launchOptions is not nil
NSDictionary *userInfo = [launchOptions valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if(application.applicationIconBadgeNumber>0)
application.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] - 1;
}
return YES;
}
I have tried by removing content-available flag.No luck.Please help me at the earliest. Here is my payload: aps = { alert = { "action-loc-key" = "ex2016"; body = { description = dakdhksadh; nid = 542; status = 1; "time_stamp" = 1474055472; title = "Push body"; type = 1; }; }; badge = 2; sound = default; }; }
iPhone 5s, iOS 9.3.1, null
Posted on Sep 18, 2016 3:14 AM