Mac App send a banner-Style local Notisfication, but My screen don't show it. when I check it, it exists in NotisficationCenter。 the code is like this:
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center requestAuthorizationWithOptions:UNAuthorizationOptionAlert|UNAuthorizationOptionBadge|UNAuthorizationOptionSound completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (error) {
NSLog(@"%@", error.description);
}
if (granted) {
[center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
if (settings.authorizationStatus == UNAuthorizationStatusAuthorized) {
UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
content.title = @"summary";
content.body = @"title";
if (settings.soundSetting == UNNotificationSettingEnabled) {
content.sound = UNNotificationSound.defaultSound;
}
UNTimeIntervalNotificationTrigger *trigger = [UNTimeIntervalNotificationTrigger triggerWithTimeInterval:1 repeats:false];
UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:NSUUID.UUID.UUIDString content:content trigger:nil];
[center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
if (error != nil) {
NSLog(@"failure");
}
}];
}
}];
} else {
return;
}
what's more weird is when I use NSUserNotificationCenter to do this operation, the notisfication just "disappear". I can't find it any where.
wish to receive your reply