RxUserNotifications 1.1.0

RxUserNotifications 1.1.0

Maintained by Paweł Rup.



 
Depends on:
RxSwift>= 0
RxCocoa>= 0
 

  • By
  • Paweł Rup

RxUserNotifications

CI Status Version License Platform Xcode Swift 5.3

Requirements

Xcode 12, Swift 5.3

Installation

Swift Package Manager

RxUserNotifications is available through Swift Package Manager. To install it, add the following line to your Package.swift into dependencies:

.package(url: "https://github.com/pawelrup/RxUserNotifications", .upToNextMinor(from: "1.1.0"))

and then add RxUserNotifications to your target dependencies.

CocoaPods

RxUserNotifications is available through CocoaPods. To install it, add the following line to your Podfile:

pod 'RxUserNotifications'

Usage

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)

Author

Paweł Rup, [email protected]

License

RxUserNotifications is available under the MIT license. See the LICENSE file for more info.