summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorEmīls <emils@mullvad.net>2023-05-11 17:44:12 +0200
committerEmīls <emils@mullvad.net>2023-05-11 17:44:12 +0200
commit4942703df9a56f798fea6aec6847c3107016daae (patch)
tree62d97e7728b938856f931cf2656855346ecdf237
parent6480310734b277f36a91b024636f5b106b31a31c (diff)
parent4ad40f5b1a8a078665457899539b9d9d02615aa9 (diff)
downloadmullvadvpn-4942703df9a56f798fea6aec6847c3107016daae.tar.xz
mullvadvpn-4942703df9a56f798fea6aec6847c3107016daae.zip
Merge branch 'fix-quirks-with-new-device-notification-ios-144'
-rw-r--r--ios/MullvadVPN.xcodeproj/project.pbxproj12
-rw-r--r--ios/MullvadVPN/AppDelegate.swift2
-rw-r--r--ios/MullvadVPN/Containers/Root/HeaderBarView.swift2
-rw-r--r--ios/MullvadVPN/Containers/Root/RootConfiguration.swift2
-rw-r--r--ios/MullvadVPN/Containers/Root/RootContainerViewController.swift4
-rw-r--r--ios/MullvadVPN/Coordinators/App/ApplicationCoordinator.swift15
-rw-r--r--ios/MullvadVPN/Notifications/InAppNotificationDescriptor.swift2
-rw-r--r--ios/MullvadVPN/Notifications/Notification Providers/AccountExpiryInAppNotificationProvider.swift4
-rw-r--r--ios/MullvadVPN/Notifications/Notification Providers/AccountExpirySystemNotificationProvider.swift8
-rw-r--r--ios/MullvadVPN/Notifications/Notification Providers/RegisteredDeviceInAppNotificationProvider.swift (renamed from ios/MullvadVPN/Notifications/Notification Providers/RegisteredDeviceInAppNotification.swift)46
-rw-r--r--ios/MullvadVPN/Notifications/Notification Providers/TunnelStatusNotificationProvider.swift4
-rw-r--r--ios/MullvadVPN/Notifications/NotificationManager.swift10
-rw-r--r--ios/MullvadVPN/Notifications/NotificationProvider.swift4
-rw-r--r--ios/MullvadVPN/Notifications/NotificationProviderIdentifier.swift21
-rw-r--r--ios/MullvadVPN/Notifications/NotificationProviderProtocol.swift2
-rw-r--r--ios/MullvadVPN/Notifications/NotificationResponse.swift2
-rw-r--r--ios/MullvadVPN/TunnelManager/TunnelBlockObserver.swift2
17 files changed, 89 insertions, 53 deletions
diff --git a/ios/MullvadVPN.xcodeproj/project.pbxproj b/ios/MullvadVPN.xcodeproj/project.pbxproj
index a9cc31cb51..c687145711 100644
--- a/ios/MullvadVPN.xcodeproj/project.pbxproj
+++ b/ios/MullvadVPN.xcodeproj/project.pbxproj
@@ -372,7 +372,8 @@
E1187ABD289BBB850024E748 /* OutOfTimeContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1187ABB289BBB850024E748 /* OutOfTimeContentView.swift */; };
E158B360285381C60002F069 /* String+AccountFormatting.swift in Sources */ = {isa = PBXBuildFile; fileRef = E158B35F285381C60002F069 /* String+AccountFormatting.swift */; };
E1FD0DF528AA7CE400299DB4 /* StatusActivityView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1FD0DF428AA7CE400299DB4 /* StatusActivityView.swift */; };
- F07CFF2029F2720E008C0343 /* RegisteredDeviceInAppNotification.swift in Sources */ = {isa = PBXBuildFile; fileRef = F07CFF1F29F2720E008C0343 /* RegisteredDeviceInAppNotification.swift */; };
+ F07CFF2029F2720E008C0343 /* RegisteredDeviceInAppNotificationProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = F07CFF1F29F2720E008C0343 /* RegisteredDeviceInAppNotificationProvider.swift */; };
+ F0C2AEFD2A0BB5CC00986207 /* NotificationProviderIdentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0C2AEFC2A0BB5CC00986207 /* NotificationProviderIdentifier.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -972,7 +973,8 @@
E1187ABB289BBB850024E748 /* OutOfTimeContentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OutOfTimeContentView.swift; sourceTree = "<group>"; };
E158B35F285381C60002F069 /* String+AccountFormatting.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+AccountFormatting.swift"; sourceTree = "<group>"; };
E1FD0DF428AA7CE400299DB4 /* StatusActivityView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusActivityView.swift; sourceTree = "<group>"; };
- F07CFF1F29F2720E008C0343 /* RegisteredDeviceInAppNotification.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegisteredDeviceInAppNotification.swift; sourceTree = "<group>"; };
+ F07CFF1F29F2720E008C0343 /* RegisteredDeviceInAppNotificationProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RegisteredDeviceInAppNotificationProvider.swift; sourceTree = "<group>"; };
+ F0C2AEFC2A0BB5CC00986207 /* NotificationProviderIdentifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationProviderIdentifier.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -1598,7 +1600,7 @@
58C8191729FAA2C400DEB1B4 /* NotificationConfiguration.swift */,
587B75402668FD7700DEF7E9 /* AccountExpirySystemNotificationProvider.swift */,
58607A4C2947287800BC467D /* AccountExpiryInAppNotificationProvider.swift */,
- F07CFF1F29F2720E008C0343 /* RegisteredDeviceInAppNotification.swift */,
+ F07CFF1F29F2720E008C0343 /* RegisteredDeviceInAppNotificationProvider.swift */,
58A94AE326CFD945001CB97C /* TunnelStatusNotificationProvider.swift */,
);
path = "Notification Providers";
@@ -1694,6 +1696,7 @@
58B26E20294351A600D5980C /* UI */,
587B75422669034500DEF7E9 /* Notification Providers */,
58B26E232943520C00D5980C /* NotificationProviderProtocol.swift */,
+ F0C2AEFC2A0BB5CC00986207 /* NotificationProviderIdentifier.swift */,
58B26E252943522400D5980C /* NotificationProvider.swift */,
58B26E1D2943514300D5980C /* InAppNotificationDescriptor.swift */,
58B26E21294351EA00D5980C /* InAppNotificationProvider.swift */,
@@ -2621,6 +2624,7 @@
5896CEF226972DEB00B0FAE8 /* AccountContentView.swift in Sources */,
7AF0419E29E957EB00D492DD /* AccountCoordinator.swift in Sources */,
5867771429097BCD006F721F /* PaymentState.swift in Sources */,
+ F0C2AEFD2A0BB5CC00986207 /* NotificationProviderIdentifier.swift in Sources */,
587D96742886D87C00CD8F1C /* DeviceManagementContentView.swift in Sources */,
589A454C28DDF5E100565204 /* Swizzle.swift in Sources */,
5864211F29F04CED00822139 /* UIBarButtonItem+Blocks.swift in Sources */,
@@ -2721,7 +2725,7 @@
582BB1AF229566420055B6EF /* SettingsCell.swift in Sources */,
58F3C0A4249CB069003E76BE /* HeaderBarView.swift in Sources */,
5864AF0829C78849005B0CD9 /* CellFactoryProtocol.swift in Sources */,
- F07CFF2029F2720E008C0343 /* RegisteredDeviceInAppNotification.swift in Sources */,
+ F07CFF2029F2720E008C0343 /* RegisteredDeviceInAppNotificationProvider.swift in Sources */,
587A01FC23F1F0BE00B68763 /* SimulatorTunnelProviderHost.swift in Sources */,
58CAF9F82983D36800BE19F7 /* Coordinator.swift in Sources */,
5819C2172729595500D6EC38 /* SettingsAddDNSEntryCell.swift in Sources */,
diff --git a/ios/MullvadVPN/AppDelegate.swift b/ios/MullvadVPN/AppDelegate.swift
index d7e54590c6..748742ee76 100644
--- a/ios/MullvadVPN/AppDelegate.swift
+++ b/ios/MullvadVPN/AppDelegate.swift
@@ -347,7 +347,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
private func setupNotificationHandler() {
NotificationManager.shared.notificationProviders = [
- RegisteredDeviceInAppNotification(tunnelManager: tunnelManager),
+ RegisteredDeviceInAppNotificationProvider(tunnelManager: tunnelManager),
TunnelStatusNotificationProvider(tunnelManager: tunnelManager),
AccountExpirySystemNotificationProvider(tunnelManager: tunnelManager),
AccountExpiryInAppNotificationProvider(tunnelManager: tunnelManager),
diff --git a/ios/MullvadVPN/Containers/Root/HeaderBarView.swift b/ios/MullvadVPN/Containers/Root/HeaderBarView.swift
index db4ec6a10e..d7cf062673 100644
--- a/ios/MullvadVPN/Containers/Root/HeaderBarView.swift
+++ b/ios/MullvadVPN/Containers/Root/HeaderBarView.swift
@@ -180,7 +180,7 @@ class HeaderBarView: UIView {
}
extension HeaderBarView {
- func update(configuration: RootConfigration) {
+ func update(configuration: RootConfiguration) {
if let name = configuration.deviceName {
let formattedDeviceName = NSLocalizedString(
"DEVICE_NAME_HEADER_VIEW",
diff --git a/ios/MullvadVPN/Containers/Root/RootConfiguration.swift b/ios/MullvadVPN/Containers/Root/RootConfiguration.swift
index 237c4acccf..0afbb7e68e 100644
--- a/ios/MullvadVPN/Containers/Root/RootConfiguration.swift
+++ b/ios/MullvadVPN/Containers/Root/RootConfiguration.swift
@@ -8,7 +8,7 @@
import Foundation
-struct RootConfigration {
+struct RootConfiguration {
var deviceName: String?
var expiry: Date?
var showsAccountButton: Bool
diff --git a/ios/MullvadVPN/Containers/Root/RootContainerViewController.swift b/ios/MullvadVPN/Containers/Root/RootContainerViewController.swift
index 1577c93020..cb8d87d94e 100644
--- a/ios/MullvadVPN/Containers/Root/RootContainerViewController.swift
+++ b/ios/MullvadVPN/Containers/Root/RootContainerViewController.swift
@@ -70,7 +70,7 @@ class RootContainerViewController: UIViewController {
let transitionContainer = UIView(frame: UIScreen.main.bounds)
private var presentationContainerAccountButton: UIButton?
private var presentationContainerSettingsButton: UIButton?
- private var configuration = RootConfigration(showsAccountButton: false, showsDeviceInfo: true)
+ private var configuration = RootConfiguration(showsAccountButton: false, showsDeviceInfo: true)
private(set) var headerBarPresentation = HeaderBarPresentation.default
private(set) var headerBarHidden = false
@@ -787,7 +787,7 @@ extension UIViewController {
}
extension RootContainerViewController {
- func update(configuration: RootConfigration) {
+ func update(configuration: RootConfiguration) {
self.configuration = configuration
presentationContainerAccountButton?.isHidden = !configuration.showsAccountButton
diff --git a/ios/MullvadVPN/Coordinators/App/ApplicationCoordinator.swift b/ios/MullvadVPN/Coordinators/App/ApplicationCoordinator.swift
index eae7d81a3f..39f2c821e5 100644
--- a/ios/MullvadVPN/Coordinators/App/ApplicationCoordinator.swift
+++ b/ios/MullvadVPN/Coordinators/App/ApplicationCoordinator.swift
@@ -20,7 +20,8 @@ private let preferredFormSheetContentSize = CGSize(width: 480, height: 640)
Application coordinator managing split view and two navigation contexts.
*/
final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewControllerDelegate,
- UISplitViewControllerDelegate, ApplicationRouterDelegate, NotificationManagerDelegate
+ UISplitViewControllerDelegate, ApplicationRouterDelegate,
+ NotificationManagerDelegate
{
/**
Application router.
@@ -707,8 +708,9 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo
switch deviceState {
case let .loggedIn(accountData, _):
+ let shouldHideDeviceInfo = previousDeviceState == .loggedOut
updateOutOfTimeTimer(accountData: accountData)
- updateView(deviceState: deviceState, showDeviceInfo: false)
+ updateView(deviceState: deviceState, showDeviceInfo: !shouldHideDeviceInfo)
// Handle transition to and from expired state.
let accountWasExpired = previousDeviceState.accountData?.isExpired ?? false
@@ -727,6 +729,7 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo
case .revoked:
cancelOutOfTimeTimer()
router.present(.revoked, animated: true)
+ updateView(deviceState: deviceState, showDeviceInfo: false)
case .loggedOut:
cancelOutOfTimeTimer()
@@ -735,7 +738,7 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo
}
private func updateView(deviceState: DeviceState, showDeviceInfo: Bool = true) {
- let configuration = RootConfigration(
+ let configuration = RootConfiguration(
deviceName: deviceState.deviceData?.capitalizedName,
expiry: deviceState.accountData?.expiry,
showsAccountButton: deviceState.isLoggedIn,
@@ -863,10 +866,12 @@ final class ApplicationCoordinator: Coordinator, Presenting, RootContainerViewCo
}
func notificationManager(_ manager: NotificationManager, didReceiveResponse response: NotificationResponse) {
- if response.providerIdentifier == AccountExpirySystemNotificationProvider.identifier {
+ switch response.providerIdentifier {
+ case .accountExpirySystemNotification:
router.present(.account)
- } else if response.providerIdentifier == RegisteredDeviceInAppNotification.identifier {
+ case .registeredDeviceInAppNotification:
updateView(deviceState: tunnelManager.deviceState)
+ default: return
}
}
diff --git a/ios/MullvadVPN/Notifications/InAppNotificationDescriptor.swift b/ios/MullvadVPN/Notifications/InAppNotificationDescriptor.swift
index f2af95365b..89825e2447 100644
--- a/ios/MullvadVPN/Notifications/InAppNotificationDescriptor.swift
+++ b/ios/MullvadVPN/Notifications/InAppNotificationDescriptor.swift
@@ -12,7 +12,7 @@ import UIKit.UIImage
/// Struct describing in-app notification.
struct InAppNotificationDescriptor: Equatable {
/// Notification identifier.
- var identifier: String
+ var identifier: NotificationProviderIdentifier
/// Notification banner style.
var style: NotificationBannerStyle
diff --git a/ios/MullvadVPN/Notifications/Notification Providers/AccountExpiryInAppNotificationProvider.swift b/ios/MullvadVPN/Notifications/Notification Providers/AccountExpiryInAppNotificationProvider.swift
index ddaa37b68b..35d38e3931 100644
--- a/ios/MullvadVPN/Notifications/Notification Providers/AccountExpiryInAppNotificationProvider.swift
+++ b/ios/MullvadVPN/Notifications/Notification Providers/AccountExpiryInAppNotificationProvider.swift
@@ -29,8 +29,8 @@ final class AccountExpiryInAppNotificationProvider: NotificationProvider, InAppN
tunnelManager.addObserver(tunnelObserver)
}
- override var identifier: String {
- return "net.mullvad.MullvadVPN.AccountExpiryInAppNotification"
+ override var identifier: NotificationProviderIdentifier {
+ .accountExpiryInAppNotification
}
// MARK: - InAppNotificationProvider
diff --git a/ios/MullvadVPN/Notifications/Notification Providers/AccountExpirySystemNotificationProvider.swift b/ios/MullvadVPN/Notifications/Notification Providers/AccountExpirySystemNotificationProvider.swift
index 4654c560d7..57452bda72 100644
--- a/ios/MullvadVPN/Notifications/Notification Providers/AccountExpirySystemNotificationProvider.swift
+++ b/ios/MullvadVPN/Notifications/Notification Providers/AccountExpirySystemNotificationProvider.swift
@@ -13,8 +13,6 @@ final class AccountExpirySystemNotificationProvider: NotificationProvider, Syste
private var accountExpiry: Date?
private var tunnelObserver: TunnelBlockObserver?
- static let identifier = "net.mullvad.MullvadVPN.AccountExpiryNotification"
-
init(tunnelManager: TunnelManager) {
super.init()
@@ -32,8 +30,8 @@ final class AccountExpirySystemNotificationProvider: NotificationProvider, Syste
self.tunnelObserver = tunnelObserver
}
- override var identifier: String {
- return Self.identifier
+ override var identifier: NotificationProviderIdentifier {
+ .accountExpirySystemNotification
}
// MARK: - SystemNotificationProvider
@@ -62,7 +60,7 @@ final class AccountExpirySystemNotificationProvider: NotificationProvider, Syste
content.sound = UNNotificationSound.default
return UNNotificationRequest(
- identifier: identifier,
+ identifier: identifier.domainIdentifier,
content: content,
trigger: trigger
)
diff --git a/ios/MullvadVPN/Notifications/Notification Providers/RegisteredDeviceInAppNotification.swift b/ios/MullvadVPN/Notifications/Notification Providers/RegisteredDeviceInAppNotificationProvider.swift
index 017d2aa1b9..2f17400610 100644
--- a/ios/MullvadVPN/Notifications/Notification Providers/RegisteredDeviceInAppNotification.swift
+++ b/ios/MullvadVPN/Notifications/Notification Providers/RegisteredDeviceInAppNotificationProvider.swift
@@ -10,23 +10,27 @@ import Foundation
import UIKit.UIColor
import UIKit.UIFont
-final class RegisteredDeviceInAppNotification: NotificationProvider, InAppNotificationProvider {
+final class RegisteredDeviceInAppNotificationProvider: NotificationProvider,
+ InAppNotificationProvider
+{
// MARK: - private properties
private let tunnelManager: TunnelManager
- private var shouldShowBanner = false
- private var deviceState: DeviceState
+ private var storedDeviceData: StoredDeviceData? {
+ tunnelManager.deviceState.deviceData
+ }
+
private var tunnelObserver: TunnelBlockObserver?
+ private var isNewDeviceRegistered = false
private var attributedBody: NSAttributedString {
- guard case let .loggedIn(_, storedDeviceData) = deviceState else { return .init(string: "") }
let formattedString = NSLocalizedString(
"ACCOUNT_CREATION_INAPP_NOTIFICATION_BODY",
value: "Welcome, this device is now called **%@**. For more details see the info button in Account.",
comment: ""
)
- let deviceName = storedDeviceData.capitalizedName
+ let deviceName = storedDeviceData?.capitalizedName ?? ""
let string = String(format: formattedString, deviceName)
return NSMutableAttributedString(markdownString: string, font: .systemFont(ofSize: 14.0)) { deviceName in
return [.foregroundColor: UIColor.InAppNotificationBanner.titleColor]
@@ -36,7 +40,7 @@ final class RegisteredDeviceInAppNotification: NotificationProvider, InAppNotifi
// MARK: - public properties
var notificationDescriptor: InAppNotificationDescriptor? {
- guard shouldShowBanner else { return nil }
+ guard isNewDeviceRegistered else { return nil }
return InAppNotificationDescriptor(
identifier: identifier,
style: .success,
@@ -49,11 +53,9 @@ final class RegisteredDeviceInAppNotification: NotificationProvider, InAppNotifi
action: .init(
image: .init(named: "IconCloseSml"),
handler: { [weak self] in
- guard let self = self else { return }
-
+ guard let self else { return }
+ self.isNewDeviceRegistered = false
self.sendAction()
-
- self.shouldShowBanner = false
self.invalidate()
}
)
@@ -62,27 +64,33 @@ final class RegisteredDeviceInAppNotification: NotificationProvider, InAppNotifi
// MARK: - initialize
- static let identifier = "net.mullvad.MullvadVPN.RegisteredDeviceInAppNotification"
-
init(tunnelManager: TunnelManager) {
self.tunnelManager = tunnelManager
- deviceState = tunnelManager.deviceState
super.init()
addObservers()
}
- override var identifier: String {
- return Self.identifier
+ override var identifier: NotificationProviderIdentifier {
+ .registeredDeviceInAppNotification
}
private func addObservers() {
tunnelObserver =
TunnelBlockObserver(didUpdateDeviceState: { [weak self] tunnelManager, deviceState, previousDeviceState in
- guard let self = self, case .loggedIn = deviceState else { return }
+ if previousDeviceState == .loggedOut,
+ case .loggedIn = deviceState
+ {
+ self?.isNewDeviceRegistered = true
+ DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1)) { [weak self] in
+ self?.invalidate()
+ }
- self.shouldShowBanner = true
- self.deviceState = deviceState
- self.invalidate()
+ } else if case .loggedIn = previousDeviceState,
+ deviceState == .loggedOut || deviceState == .revoked
+ {
+ self?.isNewDeviceRegistered = false
+ self?.invalidate()
+ }
})
tunnelObserver.flatMap { tunnelManager.addObserver($0) }
}
diff --git a/ios/MullvadVPN/Notifications/Notification Providers/TunnelStatusNotificationProvider.swift b/ios/MullvadVPN/Notifications/Notification Providers/TunnelStatusNotificationProvider.swift
index b9302211c2..acd7d1dec7 100644
--- a/ios/MullvadVPN/Notifications/Notification Providers/TunnelStatusNotificationProvider.swift
+++ b/ios/MullvadVPN/Notifications/Notification Providers/TunnelStatusNotificationProvider.swift
@@ -15,8 +15,8 @@ final class TunnelStatusNotificationProvider: NotificationProvider, InAppNotific
private var tunnelManagerError: Error?
private var tunnelObserver: TunnelBlockObserver?
- override var identifier: String {
- return "net.mullvad.MullvadVPN.TunnelStatusNotificationProvider"
+ override var identifier: NotificationProviderIdentifier {
+ return .tunnelStatusNotificationProvider
}
var notificationDescriptor: InAppNotificationDescriptor? {
diff --git a/ios/MullvadVPN/Notifications/NotificationManager.swift b/ios/MullvadVPN/Notifications/NotificationManager.swift
index d6745793f2..ee96e024bf 100644
--- a/ios/MullvadVPN/Notifications/NotificationManager.swift
+++ b/ios/MullvadVPN/Notifications/NotificationManager.swift
@@ -63,11 +63,11 @@ final class NotificationManager: NotificationProviderDelegate {
for notificationProvider in notificationProviders {
if let notificationProvider = notificationProvider as? SystemNotificationProvider {
if notificationProvider.shouldRemovePendingRequests {
- pendingRequestIdentifiersToRemove.append(notificationProvider.identifier)
+ pendingRequestIdentifiersToRemove.append(notificationProvider.identifier.domainIdentifier)
}
if notificationProvider.shouldRemoveDeliveredRequests {
- deliveredRequestIdentifiersToRemove.append(notificationProvider.identifier)
+ deliveredRequestIdentifiersToRemove.append(notificationProvider.identifier.domainIdentifier)
}
if let request = notificationProvider.notificationRequest {
@@ -120,7 +120,7 @@ final class NotificationManager: NotificationProviderDelegate {
guard let sourceProvider = notificationProviders.first(where: { notificationProvider in
guard let notificationProvider = notificationProvider as? SystemNotificationProvider else { return false }
- return response.notification.request.identifier == notificationProvider.identifier
+ return response.notification.request.identifier == notificationProvider.identifier.domainIdentifier
}) else {
logger.warning(
"Received response with request identifier: \(response.notification.request.identifier) that didn't map to any notification provider"
@@ -179,13 +179,13 @@ final class NotificationManager: NotificationProviderDelegate {
if notificationProvider.shouldRemovePendingRequests {
notificationCenter.removePendingNotificationRequests(withIdentifiers: [
- notificationProvider.identifier,
+ notificationProvider.identifier.domainIdentifier,
])
}
if notificationProvider.shouldRemoveDeliveredRequests {
notificationCenter.removeDeliveredNotifications(withIdentifiers: [
- notificationProvider.identifier,
+ notificationProvider.identifier.domainIdentifier,
])
}
diff --git a/ios/MullvadVPN/Notifications/NotificationProvider.swift b/ios/MullvadVPN/Notifications/NotificationProvider.swift
index cdcc901a67..ded3aa6b60 100644
--- a/ios/MullvadVPN/Notifications/NotificationProvider.swift
+++ b/ios/MullvadVPN/Notifications/NotificationProvider.swift
@@ -25,8 +25,8 @@ class NotificationProvider: NotificationProviderProtocol {
Override in subclasses and make sure each provider has unique identifier. It's preferred that identifiers use
reverse domain name, for instance: `com.example.app.ProviderName`.
*/
- var identifier: String {
- return "default"
+ var identifier: NotificationProviderIdentifier {
+ .default
}
/**
diff --git a/ios/MullvadVPN/Notifications/NotificationProviderIdentifier.swift b/ios/MullvadVPN/Notifications/NotificationProviderIdentifier.swift
new file mode 100644
index 0000000000..e15ec4b01e
--- /dev/null
+++ b/ios/MullvadVPN/Notifications/NotificationProviderIdentifier.swift
@@ -0,0 +1,21 @@
+//
+// NotificationProviderIdentifier.swift
+// MullvadVPN
+//
+// Created by Mojgan on 2023-05-10.
+// Copyright © 2023 Mullvad VPN AB. All rights reserved.
+//
+
+import Foundation
+
+enum NotificationProviderIdentifier: String {
+ case accountExpirySystemNotification = "AccountExpiryNotification"
+ case accountExpiryInAppNotification = "AccountExpiryInAppNotification"
+ case registeredDeviceInAppNotification = "RegisteredDeviceInAppNotification"
+ case tunnelStatusNotificationProvider = "TunnelStatusNotificationProvider"
+ case `default` = "default"
+
+ var domainIdentifier: String {
+ "net.mullvad.MullvadVPN.\(rawValue)"
+ }
+}
diff --git a/ios/MullvadVPN/Notifications/NotificationProviderProtocol.swift b/ios/MullvadVPN/Notifications/NotificationProviderProtocol.swift
index 76d92ff9c2..e4361578c9 100644
--- a/ios/MullvadVPN/Notifications/NotificationProviderProtocol.swift
+++ b/ios/MullvadVPN/Notifications/NotificationProviderProtocol.swift
@@ -12,7 +12,7 @@ import Foundation
protocol NotificationProviderProtocol {
/// Unique provider identifier used to identify notification providers and notifications
/// produced by them.
- var identifier: String { get }
+ var identifier: NotificationProviderIdentifier { get }
/// Tell notification manager to update the associated notification.
func invalidate()
diff --git a/ios/MullvadVPN/Notifications/NotificationResponse.swift b/ios/MullvadVPN/Notifications/NotificationResponse.swift
index 4b57401bec..64179e9558 100644
--- a/ios/MullvadVPN/Notifications/NotificationResponse.swift
+++ b/ios/MullvadVPN/Notifications/NotificationResponse.swift
@@ -14,7 +14,7 @@ import UserNotifications
*/
struct NotificationResponse {
/// Provider identifier.
- var providerIdentifier: String
+ var providerIdentifier: NotificationProviderIdentifier
/// Action identifier, i.e UNNotificationDefaultActionIdentifier or any custom.
var actionIdentifier: String
diff --git a/ios/MullvadVPN/TunnelManager/TunnelBlockObserver.swift b/ios/MullvadVPN/TunnelManager/TunnelBlockObserver.swift
index 90b90b5470..24fea197f3 100644
--- a/ios/MullvadVPN/TunnelManager/TunnelBlockObserver.swift
+++ b/ios/MullvadVPN/TunnelManager/TunnelBlockObserver.swift
@@ -14,7 +14,7 @@ final class TunnelBlockObserver: TunnelObserver {
typealias DidUpdateDeviceStateHandler = (
_ tunnelManager: TunnelManager,
_ deviceState: DeviceState,
- _ previousDeviceStaate: DeviceState
+ _ previousDeviceState: DeviceState
) -> Void
typealias DidUpdateTunnelSettingsHandler = (TunnelManager, TunnelSettingsV2) -> Void
typealias DidFailWithErrorHandler = (TunnelManager, Error) -> Void