I'm talking about this: http://reviews.cnet.com/8301-19512_7-20120625-233/ios-5-notifications-a-deeper-look/
Those pulldown menus on iOS, I for the love of life cannot find any documentation on how to make a notification so that it shows an update while in another application. I don't know if I just am using the wrong terminology or what, but is it "NSNotificationCenter", and where is any documentation on it?
Thanks :)
A notification dispatch mechanism that enables the broadcast of information to registered observers.
UNUserNotificationCenterDelegate. An interface for processing incoming notifications and responding to notification actions. iOS 10.0+ iPadOS 10.0+ macOS 10.14+ Mac Catalyst 13.1+ tvOS 10.0+ watchOS 3.0+
Note: You need to mark this function with @objc. That attribute makes your Swift function available in the Objective-C runtime. The NotificationCenter is part of the Objective-C runtime, so in order for it to call your function, you'll need to add that @objc attribute.
The numerical badge isn't the only property of a local notification. It can also display banners, and play sounds. These banners are subsequently added to notification center.
Here's an example:
- (void)addNotification {
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = self.datePicker.date;
localNotification.alertBody = self.messageField.text;
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.applicationIconBadgeNumber = 1;
NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:@"Object 1", @"Key 1", @"Object 2", @"Key 2", nil];
localNotification.userInfo = infoDict;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
[localNotification release];
}
And here's a tutorial: http://www.icodeblog.com/2010/07/29/iphone-programming-tutorial-local-notifications/
refer to Local and Push Notification Programming Guide by apple:
http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Introduction/Introduction.html%23//apple_ref/doc/uid/TP40008194-CH1-SW1
NSNotificationCenter
is in fact not related and provides API to pass notifications internally in the app itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With