Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# Parse-Swift Changelog

### main
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.2.6...main)
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.3.0...main)
* _Contributing to this repo? Add info about your change here to be included in the next release_

### 1.3.0
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.2.6...1.3.0)

__Improvements__
- (Breaking Change) No longer require dispatch to main queue when using ParseInstallation. The side effect of this is bade is no longer retrieved by the SDK. The developer should retrieve the badge count on their own and save it to `ParseInstallation` if they require badge ([#114](https://github.com/parse-community/Parse-Swift/pull/114)), thanks to [Corey Baker](https://github.com/cbaker6).

### 1.2.6
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.2.5...1.2.6)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,19 @@ struct Installation: ParseInstallation {
var customKey: String?
}

//: WARNING: All calls on Installation need to be done on the main queue
DispatchQueue.main.async {

/*: Save your first `customKey` value to your `ParseInstallation`.
Performs work on background queue and returns to designated on
designated callbackQueue. If no callbackQueue is specified it
returns to main queue.
*/
Installation.current?.customKey = "myCustomInstallationKey2"
Installation.current?.save { results in

switch results {
case .success(let updatedInstallation):
print("Successfully save myCustomInstallationKey to ParseServer: \(updatedInstallation)")
case .failure(let error):
print("Failed to update installation: \(error)")
}
/*: Save your first `customKey` value to your `ParseInstallation`.
Performs work on background queue and returns to designated on
designated callbackQueue. If no callbackQueue is specified it
returns to main queue.
*/
Installation.current?.customKey = "myCustomInstallationKey2"
Installation.current?.save { results in

switch results {
case .success(let updatedInstallation):
print("Successfully save myCustomInstallationKey to ParseServer: \(updatedInstallation)")
case .failure(let error):
print("Failed to update installation: \(error)")
}
}

Expand Down
2 changes: 1 addition & 1 deletion ParseSwift.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "ParseSwift"
s.version = "1.2.6"
s.version = "1.3.0"
s.summary = "Parse Pure Swift SDK"
s.homepage = "https://github.com/parse-community/Parse-Swift"
s.authors = {
Expand Down
16 changes: 8 additions & 8 deletions ParseSwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2321,7 +2321,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.2.6;
MARKETING_VERSION = 1.3.0;
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
PRODUCT_NAME = ParseSwift;
SKIP_INSTALL = YES;
Expand All @@ -2345,7 +2345,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.2.6;
MARKETING_VERSION = 1.3.0;
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
PRODUCT_NAME = ParseSwift;
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -2411,7 +2411,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 1.2.6;
MARKETING_VERSION = 1.3.0;
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
PRODUCT_NAME = ParseSwift;
SDKROOT = macosx;
Expand All @@ -2437,7 +2437,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 1.2.6;
MARKETING_VERSION = 1.3.0;
PRODUCT_BUNDLE_IDENTIFIER = com.parse.ParseSwift;
PRODUCT_NAME = ParseSwift;
SDKROOT = macosx;
Expand Down Expand Up @@ -2584,7 +2584,7 @@
INFOPLIST_FILE = "ParseSwift-watchOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.2.6;
MARKETING_VERSION = 1.3.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-watchOS";
Expand Down Expand Up @@ -2613,7 +2613,7 @@
INFOPLIST_FILE = "ParseSwift-watchOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.2.6;
MARKETING_VERSION = 1.3.0;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-watchOS";
PRODUCT_NAME = ParseSwift;
Expand All @@ -2640,7 +2640,7 @@
INFOPLIST_FILE = "ParseSwift-tvOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.2.6;
MARKETING_VERSION = 1.3.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-tvOS";
Expand Down Expand Up @@ -2668,7 +2668,7 @@
INFOPLIST_FILE = "ParseSwift-tvOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 1.2.6;
MARKETING_VERSION = 1.3.0;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.ParseSwift-tvOS";
PRODUCT_NAME = ParseSwift;
Expand Down
2 changes: 1 addition & 1 deletion Scripts/jazzy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ bundle exec jazzy \
--author_url http://parseplatform.org \
--github_url https://github.com/parse-community/Parse-Swift \
--root-url http://parseplatform.org/Parse-Swift/api/ \
--module-version 1.2.6 \
--module-version 1.3.0 \
--theme fullwidth \
--skip-undocumented \
--output ./docs/api \
Expand Down
44 changes: 6 additions & 38 deletions Sources/ParseSwift/Objects/ParseInstallation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@

import Foundation

#if canImport(UIKit)
import UIKit
#elseif canImport(AppKit)
import AppKit
#endif

/**
Objects that conform to the `ParseInstallation` protocol have a local representation of an
installation persisted to the Parse cloud. This protocol inherits from the
Expand All @@ -23,17 +17,18 @@ import AppKit

A valid `ParseInstallation` can only be instantiated via
*current* because the required identifier fields
are readonly. The `timeZone` and `badge` fields are also readonly properties which
are automatically updated to match the device's time zone and application badge
are readonly. The `timeZone` is also a readonly property which
is automatically updated to match the device's time zone
when the `ParseInstallation` is saved, thus these fields might not reflect the
latest device state if the installation has not recently been saved.

`ParseInstallation`s which have a valid `deviceToken` and are saved to
the Parse Server can be used to target push notifications. Use `setDeviceToken` to set the
`deviceToken` properly.

- warning: Only use `ParseInstallation.current` installations on the main thread as they
require UIApplication for `badge`
- warning: If the use of badge is desired, it should be retrieved by using UIKit, AppKit, etc. and
stored in `ParseInstallation.badge` before saving/updating the installation.

- warning: Linux developers should set `appName`, `appIdentifier`, and `appVersion`
manually as `ParseSwift` doesn't have access to Bundle.main.
*/
Expand Down Expand Up @@ -188,9 +183,7 @@ extension ParseInstallation {
try? KeychainStore.shared.delete(valueFor: ParseStorage.Keys.currentInstallation)
#endif
//Prepare new installation
DispatchQueue.main.async {
_ = BaseParseInstallation()
}
_ = BaseParseInstallation()
}

/**
Expand All @@ -200,7 +193,6 @@ extension ParseInstallation {
*/
public static var current: Self? {
get {
Self.currentInstallationContainer.currentInstallation?.updateBadgeFromDevice()
return Self.currentInstallationContainer.currentInstallation
}
set {
Expand All @@ -215,7 +207,6 @@ extension ParseInstallation {
mutating func updateAutomaticInfo() {
updateDeviceTypeFromDevice()
updateTimeZoneFromDevice()
updateBadgeFromDevice()
updateVersionInfoFromDevice()
updateLocaleIdentifierFromDevice()
}
Expand All @@ -239,29 +230,6 @@ extension ParseInstallation {
}
}

mutating func updateBadgeFromDevice() {
let applicationBadge: Int!

#if canImport(UIKit) && !os(watchOS)
applicationBadge = UIApplication.shared.applicationIconBadgeNumber
#elseif canImport(AppKit)
guard let currentApplicationBadge = NSApplication.shared.dockTile.badgeLabel else {
//If badgeLabel not set, assume it's 0
applicationBadge = 0
return
}
applicationBadge = Int(currentApplicationBadge)
#else
applicationBadge = 0
#endif

if badge != applicationBadge {
badge = applicationBadge
//Since this changes, update the Keychain whenever it changes
Self.saveCurrentContainerToKeychain()
}
}

mutating func updateVersionInfoFromDevice() {
guard let appInfo = Bundle.main.infoDictionary else {
return
Expand Down
4 changes: 1 addition & 3 deletions Sources/ParseSwift/Parse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ public struct ParseSwift {
ParseStorage.shared.use(keyValueStore ?? InMemoryKeyValueStore())
ParseConfiguration.sessionDelegate = ParseURLSessionDelegate(callbackQueue: .main, authentication: authentication)
//Prepare installation
DispatchQueue.main.async {
_ = BaseParseInstallation()
}
_ = BaseParseInstallation()
}

internal static func initialize(applicationId: String,
Expand Down
2 changes: 1 addition & 1 deletion Sources/ParseSwift/ParseConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation

enum ParseConstants {
static let parseVersion = "1.2.6"
static let parseVersion = "1.3.0"
static let hashingKey = "parseSwift"
static let fileManagementDirectory = "parse/"
static let fileManagementPrivateDocumentsDirectory = "Private Documents/"
Expand Down
2 changes: 1 addition & 1 deletion Sources/ParseSwift/Storage/KeychainStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func getKeychainQueryTemplate(forService service: String) -> [String: String] {
first device unlock and are not backed up.
*/
struct KeychainStore: SecureStorage {
private let synchronizationQueue: DispatchQueue
let synchronizationQueue: DispatchQueue
private let keychainQueryTemplate: [String: String]

public static var shared = KeychainStore(service: "shared")
Expand Down
Loading