Skip to content

Commit

Permalink
♻️ Update didReceiveNotification argument types
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaatttt committed May 6, 2024
1 parent 1a844d9 commit e1c7ecf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 1 addition & 2 deletions Sources/AppcuesKit/Appcues.swift
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,7 @@ public class Appcues: NSObject {
}

public func didReceiveNotification(response: UNNotificationResponse, completionHandler: @escaping () -> Void) -> Bool {
let userInfo = response.notification.request.content.userInfo
return container.resolve(PushMonitoring.self).didReceiveNotification(userInfo: userInfo, completionHandler: completionHandler)
return container.resolve(PushMonitoring.self).didReceiveNotification(response: response, completionHandler: completionHandler)
}

func initializeContainer() {
Expand Down
7 changes: 4 additions & 3 deletions Sources/AppcuesKit/Push/PushMonitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ internal protocol PushMonitoring: AnyObject {

func refreshPushStatus(completion: ((UNAuthorizationStatus) -> Void)?)

// Using `userInfo` as a parameter to be able to mock notification data.
func didReceiveNotification(userInfo: [AnyHashable: Any], completionHandler: @escaping () -> Void) -> Bool
func didReceiveNotification(response: UNNotificationResponse, completionHandler: @escaping () -> Void) -> Bool
}

internal class PushMonitor: PushMonitoring {
Expand Down Expand Up @@ -76,7 +75,9 @@ internal class PushMonitor: PushMonitoring {
}

// `completionHandler` should be called iff the function returns true.
func didReceiveNotification(userInfo: [AnyHashable: Any], completionHandler: @escaping () -> Void) -> Bool {
func didReceiveNotification(response: UNNotificationResponse, completionHandler: @escaping () -> Void) -> Bool {
let userInfo = response.notification.request.content.userInfo

config.logger.info("Push response received:\n%{private}@", userInfo.description)

guard let parsedNotification = ParsedNotification(userInfo: userInfo) else {
Expand Down

0 comments on commit e1c7ecf

Please sign in to comment.