Генерирует ошибку "Соединение XPC прервано", когда локальное уведомление запускается в XCode 8 и симулятор перестает работать
Я обновил xcode 8, а затем не могу получить локальное уведомление.
[self NotificationSettingMethod];
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"10.0"))
{
UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
content.body=[NSString stringWithFormat:@"Still not visited at %@",[dictData valueForKey:@"Name"]];
content.sound = [UNNotificationSound defaultSound];
content.badge = @([[UIApplication sharedApplication] applicationIconBadgeNumber] + 1);
UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger
triggerWithTimeInterval:10.0f repeats:NO];
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:@""content:content trigger:trigger];
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error)
{
if (!error)
{
NSLog(@"add NotificationRequest succeeded!");
}
}];
}
else
{
UILocalNotification *StillNotVisit = [[UILocalNotification alloc]init];
StillNotVisit.fireDate=[NSDate dateWithTimeIntervalSinceNow:1];
StillNotVisit.alertBody=[NSString stringWithFormat:@"Still not visited at %@",[dictData valueForKey:@"Name"]];
StillNotVisit.timeZone=[NSTimeZone defaultTimeZone];
StillNotVisit.repeatInterval = 0;
StillNotVisit.hasAction=YES;
StillNotVisit.soundName = UILocalNotificationDefaultSoundName;
}
-(void)NotificationSettingMethod
{
[self registerNotificationSettingsCompletionHandler:^(BOOL granted, NSError * _Nullable error)
{
if (!error)
{
NSLog(@"request authorization succeeded!");
}
}];
}