8
8
9
9
import Foundation
10
10
11
- #if canImport(UIKit)
12
- import UIKit
13
- #elseif canImport(AppKit)
14
- import AppKit
15
- #endif
16
-
17
11
/**
18
12
Objects that conform to the `ParseInstallation` protocol have a local representation of an
19
13
installation persisted to the Parse cloud. This protocol inherits from the
@@ -23,17 +17,18 @@ import AppKit
23
17
24
18
A valid `ParseInstallation` can only be instantiated via
25
19
*current* because the required identifier fields
26
- are readonly. The `timeZone` and `badge` fields are also readonly properties which
27
- are automatically updated to match the device's time zone and application badge
20
+ are readonly. The `timeZone` is also a readonly property which
21
+ is automatically updated to match the device's time zone
28
22
when the `ParseInstallation` is saved, thus these fields might not reflect the
29
23
latest device state if the installation has not recently been saved.
30
24
31
25
`ParseInstallation`s which have a valid `deviceToken` and are saved to
32
26
the Parse Server can be used to target push notifications. Use `setDeviceToken` to set the
33
27
`deviceToken` properly.
34
28
35
- - warning: Only use `ParseInstallation.current` installations on the main thread as they
36
- require UIApplication for `badge`
29
+ - warning: If the use of badge is desired, it should be retrieved by using UIKit, AppKit, etc. and
30
+ stored in `ParseInstallation.badge` before saving/updating the installation.
31
+
37
32
- warning: Linux developers should set `appName`, `appIdentifier`, and `appVersion`
38
33
manually as `ParseSwift` doesn't have access to Bundle.main.
39
34
*/
@@ -188,9 +183,7 @@ extension ParseInstallation {
188
183
try ? KeychainStore . shared. delete ( valueFor: ParseStorage . Keys. currentInstallation)
189
184
#endif
190
185
//Prepare new installation
191
- DispatchQueue . main. async {
192
- _ = BaseParseInstallation ( )
193
- }
186
+ _ = BaseParseInstallation ( )
194
187
}
195
188
196
189
/**
@@ -200,7 +193,6 @@ extension ParseInstallation {
200
193
*/
201
194
public static var current : Self ? {
202
195
get {
203
- Self . currentInstallationContainer. currentInstallation? . updateBadgeFromDevice ( )
204
196
return Self . currentInstallationContainer. currentInstallation
205
197
}
206
198
set {
@@ -215,7 +207,6 @@ extension ParseInstallation {
215
207
mutating func updateAutomaticInfo( ) {
216
208
updateDeviceTypeFromDevice ( )
217
209
updateTimeZoneFromDevice ( )
218
- updateBadgeFromDevice ( )
219
210
updateVersionInfoFromDevice ( )
220
211
updateLocaleIdentifierFromDevice ( )
221
212
}
@@ -239,29 +230,6 @@ extension ParseInstallation {
239
230
}
240
231
}
241
232
242
- mutating func updateBadgeFromDevice( ) {
243
- let applicationBadge : Int !
244
-
245
- #if canImport(UIKit) && !os(watchOS)
246
- applicationBadge = UIApplication . shared. applicationIconBadgeNumber
247
- #elseif canImport(AppKit)
248
- guard let currentApplicationBadge = NSApplication . shared. dockTile. badgeLabel else {
249
- //If badgeLabel not set, assume it's 0
250
- applicationBadge = 0
251
- return
252
- }
253
- applicationBadge = Int ( currentApplicationBadge)
254
- #else
255
- applicationBadge = 0
256
- #endif
257
-
258
- if badge != applicationBadge {
259
- badge = applicationBadge
260
- //Since this changes, update the Keychain whenever it changes
261
- Self . saveCurrentContainerToKeychain ( )
262
- }
263
- }
264
-
265
233
mutating func updateVersionInfoFromDevice( ) {
266
234
guard let appInfo = Bundle . main. infoDictionary else {
267
235
return
0 commit comments