2
也许我错过了一些东西,但据我所知,我正在做这件事。我正在尝试安排本地通知,但似乎从未显示。我运行该应用程序,然后点击主页按钮。在15秒内,徽章更新为1,但我从未看到警报。UILocalnotification没有在iOS7中显示
在我的视图控制器的viewDidLoad我的代码是:
[UIApplication sharedApplication].applicationIconBadgeNumber = 0;
NSDate *currentDate = [NSDate date];
NSDate *targetDate = [currentDate dateByAddingTimeInterval:15]; //15 seconds
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = targetDate;
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.alertBody = @"Body!";
localNotification.alertAction = @"Action!";
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.applicationIconBadgeNumber = 1;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
如果应用程序正在运行,我确实得到了一个电话:
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
任何想法?据我所知,这是所有正确处理。
任何在您的应用程序的通知设置? – Wain
我检查了,我甚至没有看到我的应用程序列出。对于本地通知,我是否必须像使用远程通知一样请求权限? – SonnyBurnette
就是这样。我必须注册通知。 – SonnyBurnette