Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from euforic/master
Added Native 10.8 Notifications
- Loading branch information
Showing
6 changed files
with
110 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,20 @@ | |||
// | |||
// Notice.h | |||
// MacGap | |||
// | |||
// Created by Christian Sullivan on 7/26/12. | |||
// Copyright (c) 2012 Twitter. All rights reserved. | |||
// | |||
|
|||
#import <Foundation/Foundation.h> | |||
|
|||
#define APP_NOTICE_NOTIFICATION @"Notice" | |||
|
|||
@interface Notice : NSObject <NSUserNotificationCenterDelegate> { | |||
|
|||
} | |||
|
|||
- (void) notify:(NSDictionary*)message; | |||
|
|||
@end | |||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,50 @@ | |||
// | |||
// Notice.m | |||
// MacGap | |||
// | |||
// Created by Christian Sullivan on 7/26/12. | |||
// Copyright (c) 2012 Twitter. All rights reserved. | |||
// | |||
|
|||
#import "Notice.h" | |||
|
|||
@implementation Notice | |||
|
|||
- (void) notify:(NSDictionary *)message { | |||
NSUserNotification *notification = [[NSUserNotification alloc] init]; | |||
[notification setTitle:[message valueForKey:@"title"]]; | |||
[notification setInformativeText:[message valueForKey:@"content"]]; | |||
[notification setDeliveryDate:[NSDate dateWithTimeInterval:0 sinceDate:[NSDate date]]]; | |||
[notification setSoundName:NSUserNotificationDefaultSoundName]; | |||
NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter]; | |||
[center scheduleNotification:notification]; | |||
} | |||
|
|||
#pragma mark WebScripting Protocol | |||
|
|||
+ (BOOL) isSelectorExcludedFromWebScript:(SEL)selector | |||
{ | |||
if (selector == @selector(notify:)) | |||
return NO; | |||
|
|||
return YES; | |||
} | |||
|
|||
+ (NSString*) webScriptNameForSelector:(SEL)selector | |||
{ | |||
id result = nil; | |||
|
|||
if (selector == @selector(notify:)) { | |||
result = @"notify"; | |||
} | |||
|
|||
return result; | |||
} | |||
|
|||
// right now exclude all properties (eg keys) | |||
+ (BOOL) isKeyExcludedFromWebScript:(const char*)name | |||
{ | |||
return YES; | |||
} | |||
|
|||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters