在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:LeoNatan/LNNotificationsUI开源软件地址:https://github.com/LeoNatan/LNNotificationsUI开源编程语言:Objective-C 100.0%开源软件介绍:Deprecation NoticeThis framework is no longer under active devlopment. With iOS 10, you can now display native system notifications inside your app. I suggest migrating to Apple's new API going forward. This framework remains useful for iOS 8 & 9 support. New features will likely not be implemented, but bugs may be fixed. LNNotificationsUI
See a video here. Features
Adding to Your ProjectCarthageAdd the following to your Cartfile:
ManualDrag the CocoaPodsCocoaPods is not supported. There are many reasons for this. Instead of CocoaPods, use Carthage. You can continue using CocoaPods for for your other dependencies and Carthage for Using the FrameworkProject IntegrationFirst import the umbrella header file: @import LNNotificationsUI; Registering Sub-applicationsBefore being able to post notifications, you need to register at least one sub-application with the system. Sub-applications provide a way to group notifications, each with its own identifier, name and icon and other settings. For example, a productivity app with an e-mail client and a calendar may register two sub-applications, "Mail" and "Calendar", with different icons and other more advanced settings, such calendar notifications appearing as alerts by default. [[LNNotificationCenter defaultCenter] registerApplicationWithIdentifier:@"mail_app_identifier" name:@"Mail" icon:[UIImage imageNamed:@"MailApp"] defaultSettings:[LNNotificationAppSettings defaultNotificationAppSettings]];
[[LNNotificationCenter defaultCenter] registerApplicationWithIdentifier:@"cal_app_identifier" name:@"Calendar" icon:[UIImage imageNamed:@"CalApp"] defaultSettings:[LNNotificationAppSettings defaultNotificationAppSettings]]; Note: For all available options for the default settings, take a look at the Displaying NotificationsCreate a notification object, set the desired parameters and post it. LNNotification* notification = [LNNotification notificationWithMessage:@"You've Got Mail!"];
[[LNNotificationCenter defaultCenter] presentNotification:notification forApplicationIdentifier:@"mail_app_identifier"]; Note: For all available notification properties, take a look at the Notification ActionsIn addition to displaying notifications, you can associate actions with each notification. Each notification has a default action, as well as other actions that can be attached to the notification. When the user taps a notification or the appropriate button, the provided handler block is called. LNNotification* notification = [LNNotification notificationWithMessage:@"Welcome to LNNotificationsUI!"];
notification.title = @"Hello World!";
notification.soundName = @"demo.aiff";
notification.defaultAction = [LNNotificationAction actionWithTitle:@"Default Action" handler:^(LNNotificationAction *action) {
//Handle default action
}];
notification.otherActions = @[[LNNotificationAction actionWithTitle:@"Other Action 1" handler:^(LNNotificationAction *action) {
//Handle other action here
}], [LNNotificationAction actionWithTitle:@"Other Action 2" handler:^(LNNotificationAction *action) {
//Handle other action here
}]]; Note: Currently, other actions are only available when notifications are presented as alerts. Tapping on banner notifications will call the default action handler. SettingsTo display the notification settings view controller, create an instance of |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论