blob: 67299226c5e784068abc53039074a49354124215 (
plain)
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
35
36
|
//
// NotificationProvider.swift
// MullvadVPN
//
// Created by pronebird on 09/12/2022.
// Copyright © 2022 Mullvad VPN AB. All rights reserved.
//
import Foundation
/// Notification provider delegate primarily used by `NotificationManager`.
protocol NotificationProviderDelegate: AnyObject {
func notificationProviderDidInvalidate(_ notificationProvider: NotificationProvider)
}
/// Base class for all notification providers.
class NotificationProvider: NotificationProviderProtocol {
weak var delegate: NotificationProviderDelegate?
var identifier: String {
return "default"
}
func invalidate() {
let executor = {
self.delegate?.notificationProviderDidInvalidate(self)
return
}
if Thread.isMainThread {
executor()
} else {
DispatchQueue.main.async(execute: executor)
}
}
}
|