Swiftpack.co - Package - pawelrup/RxUserNotifications

RxUserNotifications

CI Status Version License Platform Xcode Swift 5.0

Requirements

Xcode 11, Swift 5.1

Installation

Swift Package Manager

RxAVKit 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.0.0"))

and then add RxAVKit 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, pawelrup@lobocode.pl

License

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

Github

link
Stars: 2
Help us keep the lights on

Dependencies

Used By

Total: 0