Present buttons in notifications, reopen last document when none was open and user clicks on notification.

This commit is contained in:
Michael Starke
2018-09-27 13:49:24 +02:00
parent 1bed34d23f
commit 64d03ce56c
8 changed files with 67 additions and 62 deletions

View File

@@ -21,9 +21,11 @@
//
#import "MPUserNotificationCenterDelegate.h"
#import "MPDocumentController.h"
NSString *const kMPUserNotificationInfoKeyNotificationType = @"kMPUserNotificationInfoKeyNotificationType";
NSString *const kMPUserNotificationTypeAutotype = @"kMPUserNotificationTypeAutotype";
NSString *const MPUserNotificationTypeKey = @"MPUserNotificationTypeKey";
NSString *const MPUserNotificationTypeAutotypeFeedback = @"MPUserNotificationTypeAutotypeFeedback";
NSString *const MPUserNotificationTypeAutotypeOpenDocumentRequest = @"MPUserNotificationTypeAutotypeOpenDocumentRequest";
@implementation MPUserNotificationCenterDelegate
@@ -36,16 +38,14 @@ NSString *const kMPUserNotificationTypeAutotype = @"kMPUserNotificationTypeAutot
}
- (void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification {
NSLog(@"%@", notification);
NSDictionary *userInfo = notification.userInfo;
if([userInfo[MPUserNotificationTypeKey] isEqualToString:MPUserNotificationTypeAutotypeOpenDocumentRequest]) {
[((MPDocumentController*)NSDocumentController.sharedDocumentController) reopenLastDocument];
}
}
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification {
NSDictionary *userInfo = notification.userInfo;
if(!userInfo) {
return NO;
}
NSString *value = userInfo[kMPUserNotificationInfoKeyNotificationType];
return [value isEqualToString:kMPUserNotificationTypeAutotype];
return [notification.userInfo[MPUserNotificationTypeKey] isEqualToString:MPUserNotificationTypeAutotypeFeedback];
}