Skip to content

Commit 31e794b

Browse files
authored
Merge pull request #6 from messagebird/feat/update-push-notifications-example
feat: update push notifications example
2 parents 3b19a7f + 0f4fca8 commit 31e794b

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

Examples/PushNotificationsExample/PushNotificationsExample/AppDelegate.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class AppDelegate: NSObject, UIApplicationDelegate {
6060
didReceiveRemoteNotification userInfo: [AnyHashable: Any],
6161
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void
6262
) {
63-
Self.bird.notifications.applicationDidReceiveRemoteNotification(userInfo: userInfo, completionHandler: completionHandler)
63+
Self.bird.notifications.handleBackgroundNotification(userInfo: userInfo, completionHandler: completionHandler)
6464
}
6565
}
6666

@@ -81,7 +81,17 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
8181
withCompletionHandler completionHandler: @escaping () -> Void
8282
) {
8383
Self.logger.log(#function)
84-
Self.bird.notifications.didReceiveResponse(response)
84+
if let result = Self.bird.notifications.handleNotificationResponse(
85+
response: response,
86+
automaticallyOpenDeeplinks: false
87+
) {
88+
Self.logger.log("type \(result.type.rawValue)")
89+
Self.logger.log("payload \(result.payload))")
90+
Self.logger.log("action.type \(result.action.type.rawValue)")
91+
Self.logger.log("action.url \(result.action.url?.absoluteString ?? "")")
92+
Self.logger.log("action.identifier \(result.action.identifier)")
93+
94+
}
8595
completionHandler()
8696
}
8797
}

Examples/PushNotificationsExample/PushNotificationsExample/ContentView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct ContentView: View {
4040
}
4141
Text("Contact")
4242
Button("Put Attributes") {
43-
let attributes = BirdKit.Attributes().put("displayName", "Name from iOS")
43+
let attributes = BirdKit.Attributes().put("displayName", "iOS: push notifications example")
4444
AppDelegate.bird?.contact.putAttributes(attributes: attributes )
4545
}
4646

0 commit comments

Comments
 (0)