forked from confirmedcode/Lockdown-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OneTimeActions.swift
34 lines (28 loc) · 889 Bytes
/
OneTimeActions.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//
// OneTimeActions.swift
// LockdowniOS
//
// Created by Oleg Dreyman on 28.05.2020.
// Copyright © 2020 Confirmed Inc. All rights reserved.
//
import Foundation
enum OneTimeActions {
enum Flag: String {
case notificationAuthorizationRequestPopup = "LockdownHasSeenNotificationAuthorizationRequestPopup"
case oneHundredTrackingAttemptsBlockedNotification = "LockdownHasScheduledOneHundredTrackingAttemptsBlockedNotification"
}
static func hasSeen(_ flag: Flag) -> Bool {
return defaults.bool(forKey: flag.rawValue)
}
static func markAsSeen(_ flag: Flag) {
defaults.set(true, forKey: flag.rawValue)
}
static func performOnce(ifHasNotSeen flag: Flag, action: () -> ()) {
if hasSeen(flag) {
return
} else {
markAsSeen(flag)
action()
}
}
}