Skip to content

Commit 277b1fa

Browse files
authored
LOOP-1163: Unit tests for the alert facility (#67)
* DeviceAlertManager unit tests * More PR feedback renaming: Handler -> Presenter, etc. * In app modal unit tests * Finished InAppModalDeviceAlertPresenterTests * Adds UserNotificationDeviceAlertPresenterTests * LOOP-1057: Unit tests for the alert facility * comment out USE_NEW_ALERT_FACILITY code * Some more renaming from PR review * change the #if to be more obvious * One more rename suggestion from @ps2 * Rename MockHandler->MockPresenter,
1 parent 0446b33 commit 277b1fa

11 files changed

+634
-45
lines changed

Loop.xcodeproj/project.pbxproj

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@
2222
/* End PBXAggregateTarget section */
2323

2424
/* Begin PBXBuildFile section */
25-
1DA649A7244126CD00F61E75 /* UserNotificationDeviceAlertHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1DA649A6244126CD00F61E75 /* UserNotificationDeviceAlertHandler.swift */; };
26-
1DA649A9244126DA00F61E75 /* InAppModalDeviceAlertHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1DA649A8244126DA00F61E75 /* InAppModalDeviceAlertHandler.swift */; };
25+
1DA649A7244126CD00F61E75 /* UserNotificationDeviceAlertPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1DA649A6244126CD00F61E75 /* UserNotificationDeviceAlertPresenter.swift */; };
26+
1DA649A9244126DA00F61E75 /* InAppModalDeviceAlertPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1DA649A8244126DA00F61E75 /* InAppModalDeviceAlertPresenter.swift */; };
27+
1DA7A84224476EAD008257F0 /* DeviceAlertManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1DA7A84124476EAD008257F0 /* DeviceAlertManagerTests.swift */; };
28+
1DA7A84424477698008257F0 /* InAppModalDeviceAlertPresenterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1DA7A84324477698008257F0 /* InAppModalDeviceAlertPresenterTests.swift */; };
2729
1DB1065124467E18005542BD /* DeviceAlertManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1DB1065024467E18005542BD /* DeviceAlertManager.swift */; };
30+
1DFE9E172447B6270082C280 /* UserNotificationDeviceAlertPresenterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1DFE9E162447B6270082C280 /* UserNotificationDeviceAlertPresenterTests.swift */; };
2831
43027F0F1DFE0EC900C51989 /* HKUnit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F526D5E1DF2459000A04910 /* HKUnit.swift */; };
2932
4302F4E11D4E9C8900F0FCAF /* TextFieldTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4302F4E01D4E9C8900F0FCAF /* TextFieldTableViewController.swift */; };
3033
4302F4E31D4EA54200F0FCAF /* InsulinDeliveryTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4302F4E21D4EA54200F0FCAF /* InsulinDeliveryTableViewController.swift */; };
@@ -593,9 +596,12 @@
593596
/* End PBXCopyFilesBuildPhase section */
594597

595598
/* Begin PBXFileReference section */
596-
1DA649A6244126CD00F61E75 /* UserNotificationDeviceAlertHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserNotificationDeviceAlertHandler.swift; sourceTree = "<group>"; };
597-
1DA649A8244126DA00F61E75 /* InAppModalDeviceAlertHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InAppModalDeviceAlertHandler.swift; sourceTree = "<group>"; };
599+
1DA649A6244126CD00F61E75 /* UserNotificationDeviceAlertPresenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserNotificationDeviceAlertPresenter.swift; sourceTree = "<group>"; };
600+
1DA649A8244126DA00F61E75 /* InAppModalDeviceAlertPresenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InAppModalDeviceAlertPresenter.swift; sourceTree = "<group>"; };
601+
1DA7A84124476EAD008257F0 /* DeviceAlertManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceAlertManagerTests.swift; sourceTree = "<group>"; };
602+
1DA7A84324477698008257F0 /* InAppModalDeviceAlertPresenterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InAppModalDeviceAlertPresenterTests.swift; sourceTree = "<group>"; };
598603
1DB1065024467E18005542BD /* DeviceAlertManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DeviceAlertManager.swift; sourceTree = "<group>"; };
604+
1DFE9E162447B6270082C280 /* UserNotificationDeviceAlertPresenterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserNotificationDeviceAlertPresenterTests.swift; sourceTree = "<group>"; };
599605
4302F4E01D4E9C8900F0FCAF /* TextFieldTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TextFieldTableViewController.swift; sourceTree = "<group>"; };
600606
4302F4E21D4EA54200F0FCAF /* InsulinDeliveryTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InsulinDeliveryTableViewController.swift; sourceTree = "<group>"; };
601607
430B29892041F54A00BA9F93 /* NSUserDefaults.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSUserDefaults.swift; sourceTree = "<group>"; };
@@ -1213,8 +1219,26 @@
12131219
isa = PBXGroup;
12141220
children = (
12151221
1DB1065024467E18005542BD /* DeviceAlertManager.swift */,
1216-
1DA649A8244126DA00F61E75 /* InAppModalDeviceAlertHandler.swift */,
1217-
1DA649A6244126CD00F61E75 /* UserNotificationDeviceAlertHandler.swift */,
1222+
1DA649A8244126DA00F61E75 /* InAppModalDeviceAlertPresenter.swift */,
1223+
1DA649A6244126CD00F61E75 /* UserNotificationDeviceAlertPresenter.swift */,
1224+
);
1225+
path = DeviceAlert;
1226+
sourceTree = "<group>";
1227+
};
1228+
1DA7A83F24476E8C008257F0 /* Managers */ = {
1229+
isa = PBXGroup;
1230+
children = (
1231+
1DA7A84024476E98008257F0 /* DeviceAlert */,
1232+
);
1233+
path = Managers;
1234+
sourceTree = "<group>";
1235+
};
1236+
1DA7A84024476E98008257F0 /* DeviceAlert */ = {
1237+
isa = PBXGroup;
1238+
children = (
1239+
1DA7A84124476EAD008257F0 /* DeviceAlertManagerTests.swift */,
1240+
1DA7A84324477698008257F0 /* InAppModalDeviceAlertPresenterTests.swift */,
1241+
1DFE9E162447B6270082C280 /* UserNotificationDeviceAlertPresenterTests.swift */,
12181242
);
12191243
path = DeviceAlert;
12201244
sourceTree = "<group>";
@@ -1640,6 +1664,7 @@
16401664
43F78D2C1C8FC58F002152D1 /* LoopTests */ = {
16411665
isa = PBXGroup;
16421666
children = (
1667+
1DA7A83F24476E8C008257F0 /* Managers */,
16431668
43E2D90F1D20C581004DA55F /* Info.plist */,
16441669
7D2366E421250E0A0028B67D /* InfoPlist.strings */,
16451670
A9DAE7CF2332D77F006AE942 /* LoopTests.swift */,
@@ -2667,13 +2692,13 @@
26672692
C1F8B243223E73FD00DD66CF /* BolusProgressTableViewCell.swift in Sources */,
26682693
89D6953E23B6DF8A002B3066 /* PotentialCarbEntryTableViewCell.swift in Sources */,
26692694
89CA2B30226C0161004D9350 /* DirectoryObserver.swift in Sources */,
2670-
1DA649A7244126CD00F61E75 /* UserNotificationDeviceAlertHandler.swift in Sources */,
2695+
1DA649A7244126CD00F61E75 /* UserNotificationDeviceAlertPresenter.swift in Sources */,
26712696
439A7942211F631C0041B75F /* RootNavigationController.swift in Sources */,
26722697
4F11D3C020DCBEEC006E072C /* GlucoseBackfillRequestUserInfo.swift in Sources */,
26732698
43F5C2DB1B92A5E1003EB13D /* SettingsTableViewController.swift in Sources */,
26742699
89E267FC2292456700A3F2AF /* FeatureFlags.swift in Sources */,
26752700
43A567691C94880B00334FAC /* LoopDataManager.swift in Sources */,
2676-
1DA649A9244126DA00F61E75 /* InAppModalDeviceAlertHandler.swift in Sources */,
2701+
1DA649A9244126DA00F61E75 /* InAppModalDeviceAlertPresenter.swift in Sources */,
26772702
43B260491ED248FB008CAA77 /* CarbEntryTableViewCell.swift in Sources */,
26782703
4302F4E11D4E9C8900F0FCAF /* TextFieldTableViewController.swift in Sources */,
26792704
43F64DD91D9C92C900D24DC6 /* TitleSubtitleTableViewCell.swift in Sources */,
@@ -2940,8 +2965,11 @@
29402965
isa = PBXSourcesBuildPhase;
29412966
buildActionMask = 2147483647;
29422967
files = (
2968+
1DA7A84424477698008257F0 /* InAppModalDeviceAlertPresenterTests.swift in Sources */,
29432969
8968B114240C55F10074BB48 /* LoopSettingsTests.swift in Sources */,
2970+
1DA7A84224476EAD008257F0 /* DeviceAlertManagerTests.swift in Sources */,
29442971
A9DAE7D02332D77F006AE942 /* LoopTests.swift in Sources */,
2972+
1DFE9E172447B6270082C280 /* UserNotificationDeviceAlertPresenterTests.swift in Sources */,
29452973
);
29462974
runOnlyForDeploymentPostprocessing = 0;
29472975
};

Loop/AppDelegate.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
137137
}
138138
return
139139
}
140-
case NotificationManager.Action.acknowledgeAlert.rawValue:
140+
case NotificationManager.Action.acknowledgeDeviceAlert.rawValue:
141141
let userInfo = response.notification.request.content.userInfo
142-
if let alertTypeIdentifier = userInfo[LoopNotificationUserInfoKey.alertTypeId.rawValue] as? DeviceAlert.TypeIdentifier,
142+
if let alertIdentifier = userInfo[LoopNotificationUserInfoKey.alertTypeID.rawValue] as? DeviceAlert.AlertIdentifier,
143143
let managerIdentifier = userInfo[LoopNotificationUserInfoKey.managerIDForAlert.rawValue] as? String {
144144
deviceAlertManager.acknowledgeDeviceAlert(identifier:
145-
DeviceAlert.Identifier(managerIdentifier: managerIdentifier, typeIdentifier: alertTypeIdentifier))
145+
DeviceAlert.Identifier(managerIdentifier: managerIdentifier, alertIdentifier: alertIdentifier))
146146
}
147147
default:
148148
break

Loop/Managers/DeviceAlert/DeviceAlertManager.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ protocol DeviceAlertManagerResponder: class {
2020
/// - etc.
2121
public final class DeviceAlertManager {
2222

23-
var handlers: [DeviceAlertHandler] = []
23+
var handlers: [DeviceAlertPresenter] = []
2424
var responders: [String: Weak<DeviceAlertResponder>] = [:]
2525

2626
public init(rootViewController: UIViewController,
27-
isAppInBackgroundFunc: @escaping () -> Bool) {
28-
handlers = [UserNotificationDeviceAlertHandler(isAppInBackgroundFunc: isAppInBackgroundFunc),
29-
InAppModalDeviceAlertHandler(rootViewController: rootViewController, deviceAlertManagerResponder: self)]
27+
isAppInBackgroundFunc: @escaping () -> Bool,
28+
handlers: [DeviceAlertPresenter]? = nil) {
29+
self.handlers = handlers ??
30+
[UserNotificationDeviceAlertPresenter(isAppInBackgroundFunc: isAppInBackgroundFunc),
31+
InAppModalDeviceAlertPresenter(rootViewController: rootViewController, deviceAlertManagerResponder: self)]
3032
}
3133

3234
public func addAlertResponder(key: String, alertResponder: DeviceAlertResponder) {
@@ -41,12 +43,12 @@ public final class DeviceAlertManager {
4143
extension DeviceAlertManager: DeviceAlertManagerResponder {
4244
func acknowledgeDeviceAlert(identifier: DeviceAlert.Identifier) {
4345
if let responder = responders[identifier.managerIdentifier]?.value {
44-
responder.acknowledgeAlert(typeIdentifier: identifier.typeIdentifier)
46+
responder.acknowledgeAlert(alertIdentifier: identifier.alertIdentifier)
4547
}
4648
}
4749
}
4850

49-
extension DeviceAlertManager: DeviceAlertHandler {
51+
extension DeviceAlertManager: DeviceAlertPresenter {
5052

5153
public func issueAlert(_ alert: DeviceAlert) {
5254
handlers.forEach { $0.issueAlert(alert) }

Loop/Managers/DeviceAlert/InAppModalDeviceAlertHandler.swift renamed to Loop/Managers/DeviceAlert/InAppModalDeviceAlertPresenter.swift

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// InAppUserAlertHandler.swift
2+
// InAppModalDeviceAlertPresenter.swift
33
// LoopKit
44
//
55
// Created by Rick Pasetto on 4/9/20.
@@ -9,17 +9,30 @@
99
import Foundation
1010
import LoopKit
1111

12-
public class InAppModalDeviceAlertHandler: DeviceAlertHandler {
13-
12+
public class InAppModalDeviceAlertPresenter: DeviceAlertPresenter {
13+
1414
private weak var rootViewController: UIViewController?
1515
private weak var deviceAlertManagerResponder: DeviceAlertManagerResponder?
16-
16+
1717
private var alertsShowing: [DeviceAlert.Identifier: (UIAlertController, DeviceAlert)] = [:]
1818
private var alertsPending: [DeviceAlert.Identifier: (Timer, DeviceAlert)] = [:]
19+
20+
typealias ActionFactoryFunction = (String?, UIAlertAction.Style, ((UIAlertAction) -> Void)?) -> UIAlertAction
21+
private let newActionFunc: ActionFactoryFunction
1922

20-
init(rootViewController: UIViewController, deviceAlertManagerResponder: DeviceAlertManagerResponder) {
23+
typealias TimerFactoryFunction = (TimeInterval, Bool, (() -> Void)?) -> Timer
24+
private let newTimerFunc: TimerFactoryFunction
25+
26+
init(rootViewController: UIViewController,
27+
deviceAlertManagerResponder: DeviceAlertManagerResponder,
28+
newActionFunc: @escaping ActionFactoryFunction = UIAlertAction.init,
29+
newTimerFunc: TimerFactoryFunction? = nil) {
2130
self.rootViewController = rootViewController
2231
self.deviceAlertManagerResponder = deviceAlertManagerResponder
32+
self.newActionFunc = newActionFunc
33+
self.newTimerFunc = newTimerFunc ?? { timeInterval, repeats, block in
34+
return Timer.scheduledTimer(withTimeInterval: timeInterval, repeats: repeats) { _ in block?() }
35+
}
2336
}
2437

2538
public func issueAlert(_ alert: DeviceAlert) {
@@ -41,15 +54,20 @@ public class InAppModalDeviceAlertHandler: DeviceAlertHandler {
4154
}
4255

4356
public func removeDeliveredAlert(identifier: DeviceAlert.Identifier) {
57+
removeDeliveredAlert(identifier: identifier, completion: nil)
58+
}
59+
60+
// For tests only
61+
func removeDeliveredAlert(identifier: DeviceAlert.Identifier, completion: (() -> Void)?) {
4462
DispatchQueue.main.async {
45-
self.alertsShowing[identifier]?.0.dismiss(animated: true)
63+
self.alertsShowing[identifier]?.0.dismiss(animated: true, completion: completion)
4664
self.clearDeliveredAlert(identifier: identifier)
4765
}
4866
}
4967
}
5068

5169
/// Private functions
52-
extension InAppModalDeviceAlertHandler {
70+
extension InAppModalDeviceAlertPresenter {
5371

5472
private func schedule(alert: DeviceAlert, interval: TimeInterval, repeats: Bool) {
5573
guard alert.foregroundContent != nil else {
@@ -59,7 +77,7 @@ extension InAppModalDeviceAlertHandler {
5977
if self.isAlertPending(identifier: alert.identifier) {
6078
return
6179
}
62-
let timer = Timer.scheduledTimer(withTimeInterval: interval, repeats: repeats) { [weak self] timer in
80+
let timer = self.newTimerFunc(interval, repeats) { [weak self] in
6381
self?.show(alert: alert)
6482
if !repeats {
6583
self?.clearPendingAlert(identifier: alert.identifier)
@@ -119,7 +137,7 @@ extension InAppModalDeviceAlertHandler {
119137
dispatchPrecondition(condition: .onQueue(.main))
120138
// For now, this is a simple alert with an "OK" button
121139
let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
122-
alertController.addAction(UIAlertAction(title: action, style: .default, handler: { _ in completion() }))
140+
alertController.addAction(newActionFunc(action, .default, { _ in completion() }))
123141
topViewController(controller: rootViewController)?.present(alertController, animated: true)
124142
return alertController
125143
}

Loop/Managers/DeviceAlert/UserNotificationDeviceAlertHandler.swift renamed to Loop/Managers/DeviceAlert/UserNotificationDeviceAlertPresenter.swift

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// UserNotificationAlertHandler.swift
2+
// UserNotificationDeviceAlertPresenter.swift
33
// LoopKit
44
//
55
// Created by Rick Pasetto on 4/9/20.
@@ -9,34 +9,51 @@
99
import LoopKit
1010
import UserNotifications
1111

12-
class UserNotificationDeviceAlertHandler: DeviceAlertHandler {
12+
protocol UserNotificationCenter {
13+
func add(_ request: UNNotificationRequest, withCompletionHandler: ((Error?) -> Void)?)
14+
func removePendingNotificationRequests(withIdentifiers: [String])
15+
func removeDeliveredNotifications(withIdentifiers: [String])
16+
}
17+
18+
extension UNUserNotificationCenter: UserNotificationCenter {}
19+
20+
class UserNotificationDeviceAlertPresenter: DeviceAlertPresenter {
1321

14-
let alertInBackgroundOnly: Bool
22+
let alertInBackgroundOnly = true
1523
let isAppInBackgroundFunc: () -> Bool
16-
let userNotificationCenter: UNUserNotificationCenter = UNUserNotificationCenter.current()
24+
let userNotificationCenter: UserNotificationCenter
1725

18-
init(alertInBackgroundOnly: Bool = true, isAppInBackgroundFunc: @escaping () -> Bool) {
19-
self.alertInBackgroundOnly = alertInBackgroundOnly
26+
init(isAppInBackgroundFunc: @escaping () -> Bool,
27+
userNotificationCenter: UserNotificationCenter = UNUserNotificationCenter.current()) {
2028
self.isAppInBackgroundFunc = isAppInBackgroundFunc
29+
self.userNotificationCenter = userNotificationCenter
2130
}
2231

2332
func issueAlert(_ alert: DeviceAlert) {
2433
DispatchQueue.main.async {
2534
if self.alertInBackgroundOnly && self.isAppInBackgroundFunc() || !self.alertInBackgroundOnly {
2635
if let request = alert.asUserNotificationRequest() {
27-
self.userNotificationCenter.add(request)
36+
self.userNotificationCenter.add(request) { error in
37+
if let error = error {
38+
print("Something went wrong posting the user notification: \(error)")
39+
}
40+
}
2841
// For now, UserNotifications do not not acknowledge...not yet at least
2942
}
3043
}
3144
}
3245
}
3346

3447
func removePendingAlert(identifier: DeviceAlert.Identifier) {
35-
userNotificationCenter.removePendingNotificationRequests(withIdentifiers: [identifier.value])
48+
DispatchQueue.main.async {
49+
self.userNotificationCenter.removePendingNotificationRequests(withIdentifiers: [identifier.value])
50+
}
3651
}
3752

3853
func removeDeliveredAlert(identifier: DeviceAlert.Identifier) {
39-
userNotificationCenter.removeDeliveredNotifications(withIdentifiers: [identifier.value])
54+
DispatchQueue.main.async {
55+
self.userNotificationCenter.removeDeliveredNotifications(withIdentifiers: [identifier.value])
56+
}
4057
}
4158
}
4259

@@ -64,7 +81,7 @@ public extension DeviceAlert {
6481
userNotificationContent.threadIdentifier = identifier.value // Used to match categoryIdentifier, but I /think/ we want multiple threads for multiple alert types, no?
6582
userNotificationContent.userInfo = [
6683
LoopNotificationUserInfoKey.managerIDForAlert.rawValue: identifier.managerIdentifier,
67-
LoopNotificationUserInfoKey.alertTypeId.rawValue: identifier.typeIdentifier
84+
LoopNotificationUserInfoKey.alertTypeID.rawValue: identifier.alertIdentifier
6885
]
6986
return userNotificationContent
7087
}

Loop/Managers/DeviceDataManager.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ extension DeviceDataManager {
369369

370370
// MARK: - DeviceManagerDelegate
371371
extension DeviceDataManager: DeviceManagerDelegate {
372-
#if !USE_NEW_ALERT_FACILITY
372+
// #if TO BE REMOVED
373373
func scheduleNotification(for manager: DeviceManager,
374374
identifier: String,
375375
content: UNNotificationContent,
@@ -390,15 +390,15 @@ extension DeviceDataManager: DeviceManagerDelegate {
390390
func removeNotificationRequests(for manager: DeviceManager, identifiers: [String]) {
391391
UNUserNotificationCenter.current().removePendingNotificationRequests(withIdentifiers: identifiers)
392392
}
393-
#endif
393+
// #endif
394394

395395
func deviceManager(_ manager: DeviceManager, logEventForDeviceIdentifier deviceIdentifier: String?, type: DeviceLogEntryType, message: String, completion: ((Error?) -> Void)?) {
396396
deviceLog.log(managerIdentifier: Swift.type(of: manager).managerIdentifier, deviceIdentifier: deviceIdentifier, type: type, message: message, completion: completion)
397397
}
398398
}
399399

400400
// MARK: - UserAlertHandler
401-
extension DeviceDataManager: DeviceAlertHandler {
401+
extension DeviceDataManager: DeviceAlertPresenter {
402402

403403
func issueAlert(_ alert: DeviceAlert) {
404404
deviceAlertManager?.issueAlert(alert)

Loop/Managers/NotificationManager.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct NotificationManager {
1414

1515
enum Action: String {
1616
case retryBolus
17-
case acknowledgeAlert
17+
case acknowledgeDeviceAlert
1818
}
1919

2020
private static var notificationCategories: Set<UNNotificationCategory> {
@@ -33,17 +33,17 @@ struct NotificationManager {
3333
options: []
3434
))
3535

36-
let acknowledgeAlertAction = UNNotificationAction(
37-
identifier: Action.acknowledgeAlert.rawValue,
36+
let acknowledgeDeviceAlertAction = UNNotificationAction(
37+
identifier: Action.acknowledgeDeviceAlert.rawValue,
3838
title: NSLocalizedString("OK", comment: "The title of the notification action to acknowledge a device alert"),
39-
options: [.foreground]
39+
options: .foreground
4040
)
4141

4242
categories.append(UNNotificationCategory(
4343
identifier: LoopNotificationCategory.alert.rawValue,
44-
actions: [acknowledgeAlertAction],
44+
actions: [acknowledgeDeviceAlertAction],
4545
intentIdentifiers: [],
46-
options: [.customDismissAction]
46+
options: .customDismissAction
4747
))
4848

4949
return Set(categories)

0 commit comments

Comments
 (0)