Skip to content

Commit

Permalink
NetP connection notifications improvements (#2073)
Browse files Browse the repository at this point in the history
  • Loading branch information
graeme authored Oct 6, 2023
1 parent bddfc05 commit 873fb58
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
4 changes: 1 addition & 3 deletions Core/NetworkProtectionNotificationIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
import Foundation

public enum NetworkProtectionNotificationIdentifier: String {
case reconnecting = "network-protection.notification.reconnecting"
case reconnected = "network-protection.notification.reconnected"
case connectionFailure = "network-protection.notification.connection-failure"
case connection = "network-protection.notification.connection"
case superseded = "network-protection.notification.superseded"
case test = "network-protection.notification.test"
}
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8970,7 +8970,7 @@
repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 80.4.1;
version = 81.0.0;
};
};
C14882EB27F211A000D59F0C /* XCRemoteSwiftPackageReference "SwiftSoup" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"repositoryURL": "https://github.com/DuckDuckGo/BrowserServicesKit",
"state": {
"branch": null,
"revision": "9dea0583dc6269971fb4728bd3efa1ed53f88306",
"version": "80.4.1"
"revision": "5a77dc747a1bee25947b1d3ae3831922be05fd22",
"version": "81.0.0"
}
},
{
Expand All @@ -33,8 +33,8 @@
"repositoryURL": "https://github.com/duckduckgo/content-scope-scripts",
"state": {
"branch": null,
"revision": "8def15fe8a4c2fb76730f640507e9fd1d6c1f8a7",
"version": "4.32.0"
"revision": "74b6142c016be354144f28551de41b50c4864b1f",
"version": "4.37.0"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,30 @@ final class NetworkProtectionUNNotificationPresenter: NSObject, NetworkProtectio
showNotification(.test, content)
}

func showReconnectedNotification() {
func showConnectedNotification(serverLocation: String?) {
let body: String
if let serverLocation {
body = UserText.networkProtectionConnectionSuccessNotificationBody(serverLocation: serverLocation)
} else {
body = UserText.networkProtectionConnectionSuccessNotificationBody
}
let content = notificationContent(body: body)
showNotification(.connection, content)
}

func showConnectionNotification(serverLocation: String?) {
let content = notificationContent(body: UserText.networkProtectionConnectionSuccessNotificationBody)
showNotification(.reconnected, content)
showNotification(.connection, content)
}

func showReconnectingNotification() {
let content = notificationContent(body: UserText.networkProtectionConnectionInterruptedNotificationBody)
showNotification(.reconnecting, content)
showNotification(.connection, content)
}

func showConnectionFailureNotification() {
let content = notificationContent(body: UserText.networkProtectionConnectionFailureNotificationBody)
showNotification(.connectionFailure, content)
showNotification(.connection, content)
}

func showSupersededNotification() {
Expand Down
3 changes: 3 additions & 0 deletions PacketTunnelProvider/UserText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ final class UserText {

static let networkProtectionConnectionSuccessNotificationBody = NSLocalizedString("network.protection.success.notification.body", value: "Network Protection is On. Your location and online activity are protected.", comment: "The body of the notification shown when Network Protection reconnects successfully")

static func networkProtectionConnectionSuccessNotificationBody(serverLocation: String) -> String { NSLocalizedString("network.protection.success.notification.subtitle.including.serverLocation", value: "Routing device traffic through \(serverLocation).", comment: "The body of the notification shown when Network Protection connects successfully with the city + state/country as formatted parameter")
}

static let networkProtectionConnectionInterruptedNotificationBody = NSLocalizedString("network.protection.interrupted.notification.body", value: "Network Protection was interrupted. Attempting to reconnect now...", comment: "The body of the notification shown when Network Protection's connection is interrupted")

static let networkProtectionConnectionFailureNotificationBody = NSLocalizedString("network.protection.failure.notification.body", value: "Network Protection failed to connect. Please try again later.", comment: "The body of the notification shown when Network Protection fails to reconnect")
Expand Down

0 comments on commit 873fb58

Please sign in to comment.