我有一个允许设备运行更新的代码。当ipad不受iOS11下的信息引导访问(并且在iOS10和引导访问下工作)时,它可以正常工作:
- (void)viewDidLoad
{
...
UNMutableNotificationContent* content = [[UNMutableNotificationContent alloc] init];
content.title = [NSString localizedUserNotificationStringForKey:@"Update!" arguments:nil];
content.body = [NSString localizedUserNotificationStringForKey:@"Update!"
arguments:nil];
// Configure the trigger for a 7am update.
NSDateComponents* date = [[NSDateComponents alloc] init];
date.hour = 18;
date.minute = 31;
UNCalendarNotificationTrigger* trigger = [UNCalendarNotificationTrigger
triggerWithDateMatchingComponents:date repeats:NO];
// Create the request object.
UNNotificationRequest* request = [UNNotificationRequest
requestWithIdentifier:@"update" content:content trigger:trigger];
UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
if (error != nil) {
NSLog(@"%@", error.localizedDescription);
}
}];
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
willPresentNotification:(UNNotification *)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
// Update the app interface directly.
NSLog(@"");
// Play a sound.
completionHandler(UNNotificationPresentationOptionSound);
}
我发现Ticket,但没有详尽的解释来完成它:
在iOS11下是否可以在引导访问时启动通知?
提前致谢。
答案 0 :(得分:1)
看起来这只不过是iOS 11.2.5 beta 4中修复的iOS错误。有关详细信息,请参阅我自己的问题here。
如果您可以等到iOS 11.2.5发布(希望很快就会according to Apple),问题应该自行解决。否则,您需要调查类似套接字系统的内容。