पर क्लिक करते समय ऐप को कैसे खोलें मैं सूचनाओं को प्रदर्शित करने के लिए NSUserNotification का उपयोग कर रहा हूं। यह ठीक काम कर रहा है। समस्या यह है कि जब आप अधिसूचना पर क्लिक करते हैं:NSUserNotification -
- ऐप्स नोटिफिकेशन अधिसूचना केंद्र से नहीं हटाए जाते हैं।
- ऐप (जब न्यूनतम) खुला नहीं होता है।
एनएसयूसर नॉटिफिकेशन से परिचित कोई भी जो कुछ पॉइंटर्स पेश कर सकता है?
notice.m
#import "Notice.h"
@implementation Notice
- (void) notify:(NSDictionary *)message {
NSLog(@"Notification - Show it");
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];
}
- (void) userNotificationCenter:(NSUserNotificationCenter *)center didActivateNotification:(NSUserNotification *)notification
{
NSLog(@"Notification - Clicked");
notification=nil;
[center removeDeliveredNotification: 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
धन्यवाद
[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate: self]; –