Cocoa touch uilocalnotification不是从应用程序触发,而是从模拟器触发

Cocoa touch uilocalnotification不是从应用程序触发,而是从模拟器触发,cocoa-touch,uilocalnotification,Cocoa Touch,Uilocalnotification,以下是我的UILocalNotification代码: UILocalNotification *localNotification = [[UILocalNotification alloc] init]; localNotification.fireDate = aNewDate; localNotification.alertBody = alertBody; localNotification.soundName = UILocalNotificationDefaultSoundName

以下是我的UILocalNotification代码:

UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = aNewDate;
localNotification.alertBody = alertBody;
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.applicationIconBadgeNumber = 1;
localNotification.repeatInterval = NSDayCalendarUnit;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
它可以从模拟器中正常启动,但不能从我的iphone中启动。有什么建议吗

作为参考,我在“设置”中查看了通知,但我的应用程序没有出现在那里

请参见:

ios8代码:(如果目标是iOS7,则必须确保不调用这些方法…)

scheduleLocalNotification:
有一个注释:

讨论:在安排任何本地通知之前,您必须呼叫 使用
注册表通知设置:
方法通知系统 您计划向用户显示哪些类型的警报(如果有)

所以


你检查了设置,但它没有出现,这意味着你没有注册,你想把它作为一个答案,并解释如何做到这一点?我接受
    UIUserNotificationType  types = UIUserNotificationTypeAlert | UIUserNotificationTypeBadge;

    UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
    [[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];