最近我正在尝试创建一个闹钟,当我使用 UILocalNotification 时,会出现问题。当应用程序在后台时它会显示一个横幅,但是当应用程序处于活动状态时,即使我使用了didReceiveLocalNotification,也没有任何反应。为什么?
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
UIApplicationState state = application.applicationState;
if (state == UIApplicationStateActive) {
NSLog(@"RingRingRing~~~~~");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Remind" message:notification.alertBody delegate:self cancelButtonTitle:@"Sure" otherButtonTitles:nil, nil];
[alert show];
}
}