1
1
import Foundation
2
+ import BuildSettingsKit
2
3
import SFHFKeychainUtils
3
4
4
5
@objc
5
6
open class NotificationSupportService : NSObject {
7
+ private let appKeychainAccessGroup : String
8
+
9
+ @objc convenience override init ( ) {
10
+ self . init ( appKeychainAccessGroup: BuildSettings . appKeychainAccessGroup)
11
+ }
12
+
13
+ init ( appKeychainAccessGroup: String ) {
14
+ self . appKeychainAccessGroup = appKeychainAccessGroup
15
+ }
16
+
6
17
/// Sets the OAuth Token that should be used by the Notification Service Extension to access WPCOM.
7
18
///
8
19
/// - Parameter oauth2Token: WordPress.com OAuth Token
9
20
///
10
21
@objc
11
- class func insertServiceExtensionToken( _ oauthToken: String ) {
22
+ func insertServiceExtensionToken( _ oauthToken: String ) {
12
23
do {
13
24
try SFHFKeychainUtils . storeUsername (
14
25
AppConfiguration . Extension. NotificationsService. keychainTokenKey,
15
26
andPassword: oauthToken,
16
27
forServiceName: AppConfiguration . Extension. NotificationsService. keychainServiceName,
17
- accessGroup: WPAppKeychainAccessGroup ,
28
+ accessGroup: appKeychainAccessGroup ,
18
29
updateExisting: true
19
30
)
20
31
} catch {
@@ -27,13 +38,13 @@ open class NotificationSupportService: NSObject {
27
38
/// - Parameter username: WordPress.com username
28
39
///
29
40
@objc
30
- class func insertServiceExtensionUsername( _ username: String ) {
41
+ func insertServiceExtensionUsername( _ username: String ) {
31
42
do {
32
43
try SFHFKeychainUtils . storeUsername (
33
44
AppConfiguration . Extension. NotificationsService. keychainUsernameKey,
34
45
andPassword: username,
35
46
forServiceName: AppConfiguration . Extension. NotificationsService. keychainServiceName,
36
- accessGroup: WPAppKeychainAccessGroup ,
47
+ accessGroup: appKeychainAccessGroup ,
37
48
updateExisting: true
38
49
)
39
50
} catch {
@@ -46,13 +57,13 @@ open class NotificationSupportService: NSObject {
46
57
/// - Parameter userID: WordPress.com userID
47
58
///
48
59
@objc
49
- class func insertServiceExtensionUserID( _ userID: String ) {
60
+ func insertServiceExtensionUserID( _ userID: String ) {
50
61
do {
51
62
try SFHFKeychainUtils . storeUsername (
52
63
AppConfiguration . Extension. NotificationsService. keychainUserIDKey,
53
64
andPassword: userID,
54
65
forServiceName: AppConfiguration . Extension. NotificationsService. keychainServiceName,
55
- accessGroup: WPAppKeychainAccessGroup ,
66
+ accessGroup: appKeychainAccessGroup ,
56
67
updateExisting: true
57
68
)
58
69
} catch {
@@ -63,12 +74,12 @@ open class NotificationSupportService: NSObject {
63
74
/// Attempts to delete the current WPCOM OAuth Token used by the Notification Service Extension.
64
75
///
65
76
@objc
66
- class func deleteServiceExtensionToken( ) {
77
+ func deleteServiceExtensionToken( ) {
67
78
do {
68
79
try SFHFKeychainUtils . deleteItem (
69
80
forUsername: AppConfiguration . Extension. NotificationsService. keychainTokenKey,
70
81
andServiceName: AppConfiguration . Extension. NotificationsService. keychainServiceName,
71
- accessGroup: WPAppKeychainAccessGroup
82
+ accessGroup: appKeychainAccessGroup
72
83
)
73
84
} catch {
74
85
DDLogDebug ( " Error while removing Notification Service Extension OAuth token: \( error) " )
@@ -78,12 +89,12 @@ open class NotificationSupportService: NSObject {
78
89
/// Attempts to delete the current WPCOM Username used by the Notification Service Extension.
79
90
///
80
91
@objc
81
- class func deleteServiceExtensionUsername( ) {
92
+ func deleteServiceExtensionUsername( ) {
82
93
do {
83
94
try SFHFKeychainUtils . deleteItem (
84
95
forUsername: AppConfiguration . Extension. NotificationsService. keychainUsernameKey,
85
96
andServiceName: AppConfiguration . Extension. NotificationsService. keychainServiceName,
86
- accessGroup: WPAppKeychainAccessGroup
97
+ accessGroup: appKeychainAccessGroup
87
98
)
88
99
} catch {
89
100
DDLogDebug ( " Error while removing Notification Service Extension username: \( error) " )
@@ -93,12 +104,12 @@ open class NotificationSupportService: NSObject {
93
104
/// Attempts to delete the current WPCOM Username used by the Notification Service Extension.
94
105
///
95
106
@objc
96
- class func deleteServiceExtensionUserID( ) {
107
+ func deleteServiceExtensionUserID( ) {
97
108
do {
98
109
try SFHFKeychainUtils . deleteItem (
99
110
forUsername: AppConfiguration . Extension. NotificationsService. keychainUserIDKey,
100
111
andServiceName: AppConfiguration . Extension. NotificationsService. keychainServiceName,
101
- accessGroup: WPAppKeychainAccessGroup
112
+ accessGroup: appKeychainAccessGroup
102
113
)
103
114
} catch {
104
115
DDLogDebug ( " Error while removing Notification Service Extension userID: \( error) " )
0 commit comments