作者:laoshu仔 | 来源:互联网 | 2023-05-22 14:37
我正在为我的示例项目使用storyboard.该体系结构是Login View Controller和Home PageView控制器.用户单击Home PageView控制器中的按钮以启动本地通知.
-(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];
}
此代码位于AppDelegate文件中:
- (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");
}
现在,在将app推送到后台状态后,我在控制台中收到消息,但本地通知正常工作正常.
快照未呈现的视图会导致空快照.确保在屏幕更新后快照或快照之前至少渲染了一次视图.
这条消息与什么有关?