UILocalNotification 已经在 iOS10 中被废弃了。需要使用 UserNotifications.Framework 来推送通知。
获取权限
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 
 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
 UNUserNotificationCenter *unCenter = [UNUserNotificationCenter currentNotificationCenter];
 
 unCenter.delegate = self;
 
 [unCenter requestAuthorizationWithOptions:UNAuthorizationOptionSound|UNAuthorizationOptionAlert|UNAuthorizationOptionBadge completionHandler:^(BOOL granted, NSError * _Nullable error) {
 
 }];
 }
 
 #pragma mark - UNUserNotificationCenterDelegate
 
 - (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler {
 
 completionHandler();
 }
 
 |