aboutsummaryrefslogtreecommitdiffstats
path: root/notifier_darwin.m
diff options
context:
space:
mode:
authorGabriel Handford2016-05-11 16:08:20 -0700
committerGabriel Handford2016-05-11 16:08:20 -0700
commitbab68cd21095985c5d867e44f0844ab4be7c2a95 (patch)
tree0e5c34625e03d8e3ad53e0a7533f900989c75667 /notifier_darwin.m
parent27c4cb2c7539014c76232d3869052e82850fe298 (diff)
downloadgo-notifier-bab68cd21095985c5d867e44f0844ab4be7c2a95.tar.bz2
Adding actions
Diffstat (limited to 'notifier_darwin.m')
-rw-r--r--notifier_darwin.m37
1 files changed, 17 insertions, 20 deletions
diff --git a/notifier_darwin.m b/notifier_darwin.m
index 863f296..6e46b15 100644
--- a/notifier_darwin.m
+++ b/notifier_darwin.m
@@ -29,43 +29,40 @@ static BOOL installFakeBundleIdentifierHook() {
@interface NotificationDelegate : NSObject <NSUserNotificationCenterDelegate>
@end
-CFStringRef deliverNotification(CFStringRef title, CFStringRef subtitle, CFStringRef message, CFStringRef appIconURLString,
- CFStringRef bundleID, CFStringRef groupID,
- CFStringRef actionButtonTitle, CFStringRef otherButtonTitle) {
+CFStringRef deliverNotification(CFStringRef titleRef, CFStringRef subtitleRef, CFStringRef messageRef, CFStringRef appIconURLStringRef,
+ CFArrayRef actionsRef, CFStringRef bundleIDRef, CFStringRef groupIDRef) {
- if (bundleID) {
- _fakeBundleIdentifier = (NSString *)bundleID;
+ if (bundleIDRef) {
+ _fakeBundleIdentifier = (NSString *)bundleIDRef;
}
installFakeBundleIdentifierHook();
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- [defaults registerDefaults:@{@"sender": @"com.apple.Terminal"}];
-
NSUserNotification *userNotification = [[NSUserNotification alloc] init];
- userNotification.title = (NSString *)title;
- userNotification.subtitle = (NSString *)subtitle;
- userNotification.informativeText = (NSString *)message;
+ userNotification.title = (NSString *)titleRef;
+ userNotification.subtitle = (NSString *)subtitleRef;
+ userNotification.informativeText = (NSString *)messageRef;
NSMutableDictionary *options = [NSMutableDictionary dictionary];
- if (groupID) {
- options[@"groupID"] = (NSString *)groupID;
+ if (groupIDRef) {
+ options[@"groupID"] = (NSString *)groupIDRef;
}
NSString *uuid = [[NSUUID UUID] UUIDString];
options[@"uuid"] = uuid;
userNotification.userInfo = options;
- if (appIconURLString) {
- NSURL *appIconURL = [NSURL URLWithString:(NSString *)appIconURLString];
+ if (appIconURLStringRef) {
+ NSURL *appIconURL = [NSURL URLWithString:(NSString *)appIconURLStringRef];
NSImage *image = [[NSImage alloc] initWithContentsOfURL:appIconURL];
if (image) {
[userNotification setValue:image forKey:@"_identityImage"];
[userNotification setValue:@(false) forKey:@"_identityImageHasBorder"];
}
}
-
- if (actionButtonTitle) {
- userNotification.actionButtonTitle = (NSString *)actionButtonTitle;
+ NSArray *actions = (NSArray *)actionsRef;
+ if ([actions count] >= 1) {
+ userNotification.actionButtonTitle = [actions objectAtIndex:0];
+ [userNotification setValue:@YES forKey:@"_showsButtons"];
}
- if (otherButtonTitle) {
- userNotification.otherButtonTitle = (NSString *)otherButtonTitle;
+ if ([actions count] >= 2) {
+ userNotification.otherButtonTitle = [actions objectAtIndex:1];
}
NSUserNotificationCenter *userNotificationCenter = [NSUserNotificationCenter defaultUserNotificationCenter];