-
Notifications
You must be signed in to change notification settings - Fork 384
/
Copy pathBackgroundTask.swift
35 lines (28 loc) · 997 Bytes
/
BackgroundTask.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
35
//
// BackgroundTask.swift
// MullvadVPN
//
// Created by pronebird on 09/06/2023.
// Copyright © 2025 Mullvad VPN AB. All rights reserved.
//
import Foundation
/**
Background tasks defined by the app.
When adding new background tasks, don't forget to update `BGTaskSchedulerPermittedIdentifiers` key in `Info.plist` by adding a task identifier
using the following pattern:
```
$(APPLICATION_IDENTIFIER).<TaskName>
```
Note that `<TaskName>` is capitalized in plist, but the label for enum case should start with a lowercase letter.
*/
enum BackgroundTask: String {
case appRefresh, privateKeyRotation, addressCacheUpdate
/// Returns background task identifier.
/// Use it when registering or scheduling tasks with `BGTaskScheduler`.
var identifier: String {
"\(ApplicationTarget.mainApp.bundleIdentifier).\(capitalizedRawValue)"
}
private var capitalizedRawValue: String {
rawValue.prefix(1).uppercased() + rawValue.dropFirst()
}
}