Skip to content

Commit c8edb70

Browse files
committed
PushNotificationsManager: Emit ForegroundNotification to observers
1 parent bca6c86 commit c8edb70

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

WooCommerce/Classes/Notifications/PushNotificationsManager.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ final class PushNotificationsManager: PushNotesManager {
1313
///
1414
let configuration: PushNotificationsConfiguration
1515

16+
/// Mutable reference to `foregroundNotifications`.
17+
private let foregroundNotificationsSubject = PublishSubject<ForegroundNotification>()
18+
19+
/// An observable that emits values when the Remote Notifications are received while the app is
20+
/// in the foreground.
21+
///
22+
var foregroundNotifications: Observable<ForegroundNotification> {
23+
foregroundNotificationsSubject
24+
}
25+
1626
/// Returns the current Application's State
1727
///
1828
private var applicationState: UIApplication.State {
@@ -253,6 +263,8 @@ private extension PushNotificationsManager {
253263

254264
if let foregroundNotification = ForegroundNotification.from(userInfo: userInfo) {
255265
configuration.application.presentInAppNotification(message: foregroundNotification.message)
266+
267+
foregroundNotificationsSubject.send(foregroundNotification)
256268
}
257269

258270
synchronizeNotifications(completionHandler: completionHandler)

WooCommerce/Classes/ServiceLocator/PushNotesManager.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import UIKit
33

44
protocol PushNotesManager {
55

6+
/// An observable that emits values when the Remote Notifications are received while the app is
7+
/// in the foreground.
8+
///
9+
var foregroundNotifications: Observable<ForegroundNotification> { get }
10+
611
/// Resets the Badge Count.
712
///
813
func resetBadgeCount()

0 commit comments

Comments
 (0)