Iphone UILocalNotification未出现在iOS7中

Iphone UILocalNotification未出现在iOS7中,iphone,objective-c,ios6,ios7,uilocalnotification,Iphone,Objective C,Ios6,Ios7,Uilocalnotification,我在项目中使用UILocalNotification。我的代码: UILocalNotification *notification = [[UILocalNotification alloc] init]; notification.fireDate = event.date; notification.timeZone = [NSTimeZone systemTimeZone]; notification.ha

我在项目中使用UILocalNotification。我的代码:

        UILocalNotification *notification = [[UILocalNotification alloc] init];
        notification.fireDate = event.date;
        notification.timeZone = [NSTimeZone systemTimeZone];        

        notification.hasAction = YES;
        notification.soundName = UILocalNotificationDefaultSoundName;
        [notification setApplicationIconBadgeNumber:[UIApplication sharedApplication].applicationIconBadgeNumber+1];

        notification.alertBody = @"test alert body";

        notification.repeatInterval = NSDayCalendarUnit;

        NSLog(@"SCHEDULED NOTIFICATION  = %@", notification);

        [[UIApplication sharedApplication] scheduleLocalNotification:notification];
当通知出现时,除了应用程序的徽章图标值获得+1外,不会发生任何事情。对于iOS6来说,它的工作很好。哪里会有问题


更新在我的应用程序运行和关闭时,我不会收到任何通知通知。Ony徽章号码正在更改

如果在前台运行,则通常会缺少
didReceiveLocalNotification

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {

    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:[[[NSBundle mainBundle] infoDictionary]   objectForKey:@"CFBundleName"]
                                                        message:notification.alertBody
                                                       delegate:nil
                                              cancelButtonTitle:@"OK"
                                              otherButtonTitles:nil];

    [alertView show];

    // Reset badges if you want
    application.applicationIconBadgeNumber = 0;
}

找到此问题的解决方法()


只需将通知延迟几毫秒即可。在我的情况下(短信应用程序),它工作得很好。

另一个可能的问题是你已经拒绝了应用程序的推送通知。即使它说“允许推送通知”,弹出窗口实际上控制所有通知;推送和本地


只需确保检查您的设置->通知中心->应用程序名称。我浪费了一个小时试图找出哪里出了问题,结果我只是禁用了推送功能--

请在后台模式下检查…看,答案是你在didReceiveLocalNotification方法中收到回调?还是你设置菜单中没有的通知样式?@Deepesh你的意思是什么?你如何确保应用程序是正确的被认为是在前景-没有被提及是的,你是对的。我不知道。这是一个假设,因为我曾经遇到过类似的问题,没有显示对话框。