To run the example project, clone the repo, and run pod install from the Example directory first.
BSForegroundNotification is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "BSForegroundNotification"If you used use_framework in your podfile just simply do:
import BSForegroundNotificationfor every file when you need to use it.
you may also use:
@import BSForegroundNotificationwithin bridging header file and avoid to import framework for every needed file.
##Info
- entirely written in latest Swift syntax. Works with iOS 8 and 9 and Xcode7.
- to present local foreground notification, both
alertTitleandalertBodycannot be nil - to present remote foreground notification, both
titleandbodycannot be nil inalertdictionary. In case whenalertis a string, that string cannot be empty.
##Usage
######Simply create your foreground notification object with on of three ways:
let notification = BSForegroundNotification(userInfo: userInfo) //remote
let notification = BSForegroundNotification(localNotification: localNotification) //local
let notification = BSForegroundNotification(titleLabel: "title", subtitleLabel: "subtitle", categoryIdentifier: "category") //custom initializer######Set a default dismissal time for the notification:
notification.timeToDismissNotification = 10 //4 is by default######Set delegate which conform to protocol BSForegroundNotificationDelegate:
Note that BSForegroundNotificationDelegate inherits from UIApplicationsDelegate
notification.delegate = self######Implement optional methods of BSForegroundNotificationDelegate
@objc public protocol BSForegroundNotificationDelegate: class, UIApplicationDelegate {
optional func foregroundRemoteNotificationWasTouched(with userInfo: [AnyHashable: Any])
optional func foregroundLocalNotificationWasTouched(with localNotification: UILocalNotification)
}######Then present notification:
notification.presentNotification()######If it is needed one of BSForegroundNotificationDelegate's method is called':
func application(application: UIApplication, handleActionWithIdentifier identifier: String?, forRemoteNotification userInfo: [AnyHashable: Any], completionHandler: () -> Void)
func application(application: UIApplication, handleActionWithIdentifier identifier: String?, forRemoteNotification userInfo: [AnyHashable: Any], withResponseInfo responseInfo: [AnyHashable: Any], completionHandler: () -> Void)
func application(application: UIApplication, handleActionWithIdentifier identifier: String?, forLocalNotification notification: UILocalNotification, completionHandler: () -> Void)
func application(application: UIApplication, handleActionWithIdentifier identifier: String?, forLocalNotification notification: UILocalNotification, withResponseInfo responseInfo: [AnyHashable: Any], completionHandler: () -> Void)######Class properties:
You can set your own sound using systemSoundID class property:
BSForegroundNotification.systemSoundID = 1002 //1001 is by default
Bartłomiej Semańczyk, bartekss2@icloud.com
BSForegroundNotification is available under the MIT license. See the LICENSE file for more info.





