Skip to content

Commit c517e02

Browse files
committed
Track notification dismiss event.
1 parent 8225f27 commit c517e02

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

WooCommerce/Classes/Analytics/WooAnalyticsStat.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public enum WooAnalyticsStat: String {
3939
case loginJetpackRequiredScreenViewed = "login_jetpack_required_screen_viewed"
4040
case loginJetpackRequiredViewInstructionsButtonTapped = "login_jetpack_required_view_instructions_button_tapped"
4141
case loginLocalNotificationTapped = "login_local_notification_tapped"
42+
case loginLocalNotificationDismissed = "login_local_notification_dismissed"
4243
case loginWhatIsJetpackHelpScreenViewed = "login_what_is_jetpack_help_screen_viewed"
4344
case loginWhatIsJetpackHelpScreenOkButtonTapped = "login_what_is_jetpack_help_screen_ok_button_tapped"
4445
case loginWhatIsJetpackHelpScreenLearnMoreButtonTapped = "login_what_is_jetpack_help_screen_learn_more_button_tapped"

WooCommerce/Classes/Notifications/PushNotificationsManager.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,10 @@ extension PushNotificationsManager {
324324
intentIdentifiers: [],
325325
hiddenPreviewsBodyPlaceholder: nil,
326326
categorySummaryFormat: nil,
327-
options: .allowAnnouncement)
327+
// `customDismissAction` option is required for the dismiss action callback in
328+
// `UNUserNotificationCenterDelegate.userNotificationCenter(_:didReceive:)`
329+
// with action identifier `UNNotificationDismissActionIdentifier`.
330+
options: .customDismissAction)
328331
center.setNotificationCategories([category])
329332
content.categoryIdentifier = categoryIdentifier
330333
}

WooCommerce/Classes/ViewRelated/AppCoordinator.swift

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ private extension AppCoordinator {
250250
"action": "contact_support",
251251
"type": response.notification.request.identifier
252252
])
253-
default:
253+
case UNNotificationDefaultActionIdentifier:
254254
// Triggered when the user taps on the notification itself instead of one of the actions.
255255
switch response.notification.request.identifier {
256256
case LocalNotification.Scenario.loginSiteAddressError.rawValue:
@@ -259,8 +259,20 @@ private extension AppCoordinator {
259259
"type": response.notification.request.identifier
260260
])
261261
default:
262-
return
262+
break
263263
}
264+
case UNNotificationDismissActionIdentifier:
265+
// Triggered when the user taps on the notification's "Clear" action.
266+
switch response.notification.request.identifier {
267+
case LocalNotification.Scenario.loginSiteAddressError.rawValue:
268+
analytics.track(.loginLocalNotificationDismissed, withProperties: [
269+
"type": response.notification.request.identifier
270+
])
271+
default:
272+
break
273+
}
274+
default:
275+
break
264276
}
265277
}
266278
}

0 commit comments

Comments
 (0)