I use a storyboard for my sample project. The architecture is the login controller and the Home PageView controller. The user presses a button on the Home PageView controller to trigger a local notification.
-(IBAction)startLocalNotification { // Bind this method to UIButton action NSLog(@"startLocalNotification"); UILocalNotification *notification = [[UILocalNotification alloc] init]; notification.fireDate = [NSDate dateWithTimeIntervalSinceNow:7]; notification.alertBody = @"This is local notification!"; notification.timeZone = [NSTimeZone defaultTimeZone]; notification.soundName = UILocalNotificationDefaultSoundName; notification.applicationIconBadgeNumber = 10; [[UIApplication sharedApplication] scheduleLocalNotification:notification]; }
This code is in the AppDelegate file:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){ [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]]; } [launchOptions valueForKey:UIApplicationLaunchOptionsLocalNotificationKey]; // Override point for customization after application launch. return YES; } - (void)applicationDidBecomeActive:(UIApplication *)application { [UIApplication sharedApplication].applicationIconBadgeNumber = 0; NSLog(@"didReceiveLocalNotification"); }
Now after clicking the application in the background, I get the message below in the console, but the local notification works fine, as expected.
A snapshot of a snapshot that was not displayed results in blank snapshots. Make sure your view has been viewed at least once before the snapshot or after snapshots.
What is the reason for this message?
Jayprakash dubey
source share