-
Notifications
You must be signed in to change notification settings - Fork 27
/
PushConfiguration.swift
82 lines (69 loc) · 3.34 KB
/
PushConfiguration.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import Foundation
public enum PushConfigurationLabel: String {
case fennec = "Fennec"
case fennecEnterprise = "FennecEnterprise"
case firefoxBeta = "FirefoxBeta"
case firefoxNightlyEnterprise = "FirefoxNightly"
case firefox = "Firefox"
public func toConfiguration() -> PushConfiguration {
switch self {
case .fennec: return FennecPushConfiguration()
case .fennecEnterprise: return FennecEnterprisePushConfiguration()
case .firefoxBeta: return FirefoxBetaPushConfiguration()
case .firefoxNightlyEnterprise: return FirefoxNightlyEnterprisePushConfiguration()
case .firefox: return FirefoxPushConfiguration()
}
}
}
public protocol PushConfiguration {
var label: PushConfigurationLabel { get }
/// The associated autopush server should speak the protocol documented at
/// http://autopush.readthedocs.io/en/latest/http.html#push-service-http-api
/// /v1/{type}/{app_id}
/// type == apns
/// app_id == the “platform” or “channel” of development (e.g. “firefox”, “beta”, “gecko”, etc.)
var endpointURL: NSURL { get }
}
public struct FennecPushConfiguration: PushConfiguration {
public init() {}
public let label = PushConfigurationLabel.fennec
public let endpointURL = NSURL(string: "https://updates.push.services.mozilla.com/v1/apns/fennec")!
}
public struct FennecStagingPushConfiguration: PushConfiguration {
public init() {}
public let label = PushConfigurationLabel.fennec
public let endpointURL = NSURL(string: "https://updates-autopush.stage.mozaws.net/v1/apns/fennec")!
}
public struct FennecEnterprisePushConfiguration: PushConfiguration {
public init() {}
public let label = PushConfigurationLabel.fennecEnterprise
public let endpointURL = NSURL(string: "https://updates.push.services.mozilla.com/v1/apns/fennecenterprise")!
}
public struct FirefoxBetaPushConfiguration: PushConfiguration {
public init() {}
public let label = PushConfigurationLabel.firefoxBeta
public let endpointURL = NSURL(string: "https://updates.push.services.mozilla.com/v1/apns/firefoxbeta")!
}
public struct FirefoxBetaStagingPushConfiguration: PushConfiguration {
public init() {}
public let label = PushConfigurationLabel.firefoxBeta
public let endpointURL = NSURL(string: "https://updates-autopush.stage.mozaws.net/v1/apns/firefoxbeta")!
}
public struct FirefoxNightlyEnterprisePushConfiguration: PushConfiguration {
public init() {}
public let label = PushConfigurationLabel.firefoxNightlyEnterprise
public let endpointURL = NSURL(string: "https://updates.push.services.mozilla.com/v1/apns/firefoxnightlyenterprise")!
}
public struct FirefoxPushConfiguration: PushConfiguration {
public init() {}
public let label = PushConfigurationLabel.firefox
public let endpointURL = NSURL(string: "https://updates.push.services.mozilla.com/v1/apns/firefox")!
}
public struct FirefoxStagingPushConfiguration: PushConfiguration {
public init() {}
public let label = PushConfigurationLabel.firefox
public let endpointURL = NSURL(string: "https://updates-autopush.stage.mozaws.net/v1/apns/firefox")!
}