I want to post a notification to the NSUserNotificationCenter when a certain
event happens in my app (the user is able to toggle which events cause
notifications). It’s working, but not how I want. I can’t find the
documentation that tells me what I need to know.
What I want:
For EVERY event of the given kind, a notification is posted. The notification
should show an alert to the user in the top corner for a few seconds if the app
is not active, then disappear on its own. If there are several at once (rare,
but possible), then all of the alerts should be shown, stackwise. The
Notification bar should keep the last three or four, maybe up to a set time
period.
The way iTunes notifies the current playing track is pretty close to what I
want.
What I get:
Only the first such event results in a notification in the notification bar,
all the others are just not shown at all. There is no alert unless the machine
is in screensaver mode. The first notification never goes away.
Obviously it’s a case of configuring the notifications, but there’s nothing I
can find that clearly sets out what effect each setting has. The Nofication
options in Sys Prefs for the app is set to show banners, 5 recent items, and
all options checked (the default, in other words). This is the same as iTunes,
which behaves more or less the way I want mine to work.
Also, I’m using the -deliverNotification: method to post the notifications,
rather than schedule them. That might be wrong. Each notificaiton I post has a
different identifier relating to the item it corresponds to. I don’t currently
use a delegate, maybe I need to.
The code:
if( self.userNotificationOption & kXVMediaNotifyOnline )
{
NSUserNotification* note =
[[[NSUserNotification alloc] init] autorelease];
note.title = self.name;
note.subtitle = NSLocalizedString(@“Something
happened", nil);
note.informativeText = self.finder.subject;
note.hasActionButton = NO;
note.identifier = self.URL.absoluteString;
[[NSUserNotificationCenter
defaultUserNotificationCenter] deliverNotification:note];
}
I’m off to experiment, but if anyone knows how to tame the beast, it would save
me some time.
thanks,
--Graham
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]