To run the example project, clone the repo, and run pod install from the Example directory first.
Xcode 10, Swift 4.2
RxUserNotifications is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'RxUserNotifications'Simply subscribe to willPresentNotification or didReceiveResponse like below:
let center = UNUserNotificationCenter.current()
// Presenting notification when app is in foreground.
center.rx.willPresentNotification
.subscribe(onNext: { (notification: UNNotification, completion: UNUserNotificationCenter.WillPresentNotificationCompletionHandler) in
// Do something
completion([.badge, .alert, .sound])
})
.disposed(by: disposeBag)
// Receiving user response
center.rx.didReceiveResponse
.subscribe(onNext: { (response: UNNotificationResponse, completion: UNUserNotificationCenter.DidReceiveResponseCompletionHandler) in
// Do something
completion()
})
.disposed(by: disposeBag)lobocode, pawelrup@lobocode.pl
RxUserNotifications is available under the MIT license. See the LICENSE file for more info.