Skip to content

Commit e58fd2a

Browse files
committed
Add "Log in with WordPress.com" action to site address error local notification.
1 parent 511381d commit e58fd2a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

WooCommerce/Classes/Notifications/LocalNotification.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@ struct LocalNotification {
2727
/// The action type in a local notification.
2828
enum Action: String {
2929
case contactSupport
30+
case loginWithWPCom
3031

3132
/// The title of the action in a local notification.
3233
var title: String {
3334
switch self {
3435
case .contactSupport:
3536
return NSLocalizedString("Contact support", comment: "Local notification action to contact support.")
37+
case .loginWithWPCom:
38+
return NSLocalizedString("Login with WordPress.com", comment: "Local notification action to log in with WordPress.com.")
3639
}
3740
}
3841
}
@@ -45,7 +48,7 @@ extension LocalNotification {
4548
self.init(title: Localization.errorLoggingInTitle,
4649
body: Localization.errorLoggingInBody,
4750
scenario: .loginSiteAddressError,
48-
actions: .init(category: .loginError, actions: [.contactSupport]))
51+
actions: .init(category: .loginError, actions: [.contactSupport, .loginWithWPCom]))
4952
}
5053
}
5154
}

WooCommerce/Classes/ViewRelated/AppCoordinator.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Combine
22
import Experiments
33
import UIKit
4+
import WordPressAuthenticator
45
import Yosemite
56
import class AutomatticTracks.CrashLogging
67

@@ -253,6 +254,17 @@ private extension AppCoordinator {
253254
"action": "contact_support",
254255
"type": response.notification.request.identifier
255256
])
257+
case LocalNotification.Action.loginWithWPCom.rawValue:
258+
guard let loginNavigationController = window.rootViewController as? LoginNavigationController,
259+
let viewController = loginNavigationController.topViewController else {
260+
return
261+
}
262+
let command = NavigateToEnterAccount()
263+
command.execute(from: viewController)
264+
analytics.track(.loginLocalNotificationTapped, withProperties: [
265+
"action": "login_with_wpcom",
266+
"type": response.notification.request.identifier
267+
])
256268
case UNNotificationDefaultActionIdentifier:
257269
// Triggered when the user taps on the notification itself instead of one of the actions.
258270
switch response.notification.request.identifier {

0 commit comments

Comments
 (0)