Tag: usernotifications

本地通知不会在ios10中触发

我正在使用UNUserNotificationCenter的ios 10.为了testing,我设置了从当前时间10秒的本地通知。 这是我试过的, – (void)viewDidLoad { [super viewDidLoad]; UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; [center requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert) completionHandler:^(BOOL granted, NSError * _Nullable error) { if (!error) { NSLog(@"request succeeded!"); [self set10Notifs]; } }]; } -(void) set10Notifs { if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"10.0")) { #if XCODE_VERSION_GREATER_THAN_OR_EQUAL_TO_8 NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian]; [calendar setTimeZone:[NSTimeZone localTimeZone]]; NSDateComponents *components […]

多个UNUserNotifications不能触发

我正在设置多个UNUsernotifications如下, – (void)viewDidLoad { [super viewDidLoad]; notifCount = 0; UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; [center requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert) completionHandler:^(BOOL granted, NSError * _Nullable error) { if (!error) { NSLog(@"request succeeded!"); [self set10Notif]; } }]; } 在set10Notif方法中,我将当前时间设置为10秒的多个(8testing)通知。 -(void) set10Notif { notifCount = notifCount+1; if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"10.0") && notifCount < 10) { // create actions NSCalendar […]