UserNotification未显示(iOS 10)

我无法在iOS 10中UserNotification 。我将从我的代码开始:

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; UNAuthorizationOptions options = (UNAuthorizationOptionBadge | UNAuthorizationOptionAlert | UNAuthorizationOptionSound); center.delegate = self; [center requestAuthorizationWithOptions: options completionHandler: ^(BOOL granted, NSError * _Nullable error) { if (granted) { NSLog(@"Granted notifications!"); } }]; // 

这工作,我看到日志。

那么,我有:

 -(void)application: (UIApplication *)application performFetchWithCompletionHandler: (void (^)(UIBackgroundFetchResult))completionHandler { // UNMutableNotificationContent *content = [UNMutableNotificationContent new]; content.title = NSLocalizedString(@"Updates are available", nil); UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval: 1 repeats: NO]; UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier: @"IDLocalNotification" content: content trigger: trigger]; UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; [center addNotificationRequest: request withCompletionHandler: ^(NSError * _Nullable error) { if (!error) { NSLog(@"Notification was requested!"); } }]; 

再次,这工作,我看到日志。

但我没有看到通知出现在我的屏幕上(触发延迟只有1秒,但我尝试了更大的值)。

此外, willPresentNotification委托方法永远不会到达。

我错过了什么?

发现问题。

事实certificate,我需要设置内容的body ,而不仅仅是title

 UNMutableNotificationContent *content = [UNMutableNotificationContent new]; content.body = [NSString localizedUserNotificationStringForKey: @"Updates are available" arguments: nil]; 

我甚至可以离开title ,它的作品。