-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Persist ParseUser, ParseInstallation, and default ACL in Keychain (#19)
* add ACL tests with ACL fixes * bump codecov * Increase timeout * reduce test threads * Store ParseUser and default ACL to Keychain. Additional fixes: - Add updated badges - Bump minimus iOS support to iOS9 - Send codecov reports for all builds * Make logoutAsync thread test pass * Add more code coverage * reduce codecov * Use BaseParseUser to get currentUser from Keychain * Add initial documentation * Bump minimum deployment for all OSs. Add initial version of ParseInstallation, still needs test cases * Fix watchOS build * Really fix watchOS build * Bump OS versions in podspec * Finish Installation support with unit tests. Also cleaned up file structure * Add back old ParseUser threading test. Bump codecov * Improve Keychain Installation tests * Update installation in keychain whenever a badge update occurs * Only persist BaseParseUser and BaseInstallation values to keychain. Added updated saving of User and Installation during fetch, find, first. Additional updates - updated some documentation (still more to do) - Deleted unnecessary files * Removed threadSafe SignUp, Login, and Logout since these are unrealistic. For example, 100 signup threads won't be created to sign up a user * Only use ParseInstall on main thread * Updates * update documentation * More updates to documentation * Update README.md * Use Queryable protocol * make links point to main branch * documentation fixes * Change source of logo image to show in docs * Updates with broken login * fixed URL components contruction along with adding body. Added improved examples in playgrounds * Add Install example to playgrounds. Clean up Query * Improve playgrounds and add ACL example * Switch ACL value type name to ParseACL as it causes issues with parse-server JSON key "ACL". It also prevents you from using var ACL = ACL.defaultACL(). So we now use var ACL = ParseACL.defaultACL() instead. * Fix ACL saving to parse-server * Partially fixed decoding ParseError from ParseServer. Still doesn't decode message. * Fixed decoding ParseError from server * Updates to Query * Added constants enum * Update constants enum Co-authored-by: Tom Fox <13188249+TomWFox@users.noreply.github.com>
- Loading branch information
Showing
52 changed files
with
3,044 additions
and
523 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,6 @@ coverage: | |
changes: false | ||
project: | ||
default: | ||
target: 52 | ||
target: 63 | ||
comment: | ||
require_changes: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
146 changes: 146 additions & 0 deletions
146
ParseSwift.playground/Pages/1 - Your first Object.xcplaygroundpage/Contents.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
//: [Previous](@previous) | ||
|
||
import PlaygroundSupport | ||
import Foundation | ||
import ParseSwift | ||
PlaygroundPage.current.needsIndefiniteExecution = true | ||
|
||
//: start parse-server with | ||
//: npm start -- --appId applicationId --clientKey clientKey --masterKey masterKey --mountPath /1 | ||
|
||
initializeParse() | ||
|
||
//: Create your own ValueTyped ParseObject | ||
struct GameScore: ParseObject { | ||
//: Those are required for Object | ||
var objectId: String? | ||
var createdAt: Date? | ||
var updatedAt: Date? | ||
var ACL: ParseACL? | ||
|
||
//: Your own properties | ||
var score: Int | ||
|
||
//: a custom initializer | ||
init(score: Int) { | ||
self.score = score | ||
} | ||
} | ||
|
||
//: Define initial GameScores | ||
let score = GameScore(score: 10) | ||
let score2 = GameScore(score: 3) | ||
|
||
/*: Query asynchronously (preferred way) - Performs work on background | ||
queue and returns to designated on designated callbackQueue. | ||
If no callbackQueue is specified it returns to main queue. | ||
*/ | ||
score.save { result in | ||
switch result { | ||
case .success(let savedScore): | ||
assert(savedScore.objectId != nil) | ||
assert(savedScore.createdAt != nil) | ||
assert(savedScore.updatedAt != nil) | ||
assert(savedScore.ACL == nil) | ||
assert(savedScore.score == 10) | ||
|
||
/*: To modify, need to make it a var as the Value Type | ||
was initialized as immutable | ||
*/ | ||
var changedScore = savedScore | ||
changedScore.score = 200 | ||
changedScore.save { result in | ||
switch result { | ||
case .success(var savedChangedScore): | ||
assert(savedChangedScore.score == 200) | ||
assert(savedScore.objectId == savedChangedScore.objectId) | ||
|
||
/*: Note that savedChangedScore is mutable since it's | ||
a var after success. | ||
*/ | ||
savedChangedScore.score = 500 | ||
|
||
case .failure(let error): | ||
assertionFailure("Error saving: \(error)") | ||
} | ||
} | ||
case .failure(let error): | ||
assertionFailure("Error saving: \(error)") | ||
} | ||
} | ||
|
||
//: Saving multiple GameScores at once | ||
[score, score2].saveAll { results in | ||
switch results { | ||
case .success(let otherResults): | ||
otherResults.forEach { otherResult in | ||
switch otherResult { | ||
case .success(let savedScore): | ||
print("Saved \"\(savedScore.className)\" with score \(savedScore.score) successfully") | ||
|
||
case .failure(let error): | ||
assertionFailure("Error saving: \(error)") | ||
} | ||
} | ||
|
||
case .failure(let error): | ||
assertionFailure("Error saving: \(error)") | ||
} | ||
} | ||
|
||
//: Save synchronously (not preferred - all operations on main queue) | ||
let savedScore: GameScore? | ||
do { | ||
savedScore = try score.save() | ||
} catch { | ||
savedScore = nil | ||
fatalError("Error saving: \(error)") | ||
} | ||
|
||
assert(savedScore != nil) | ||
assert(savedScore?.objectId != nil) | ||
assert(savedScore?.createdAt != nil) | ||
assert(savedScore?.updatedAt != nil) | ||
assert(savedScore?.score == 10) | ||
|
||
/*: To modify, need to make it a var as the Value Type | ||
was initialized as immutable | ||
*/ | ||
guard var changedScore = savedScore else { | ||
fatalError() | ||
} | ||
changedScore.score = 200 | ||
|
||
let savedChangedScore: GameScore? | ||
do { | ||
savedChangedScore = try changedScore.save() | ||
} catch { | ||
savedChangedScore = nil | ||
fatalError("Error saving: \(error)") | ||
} | ||
|
||
assert(savedChangedScore != nil) | ||
assert(savedChangedScore!.score == 200) | ||
assert(savedScore!.objectId == savedChangedScore!.objectId) | ||
|
||
let otherResults: [(Result<GameScore, ParseError>)]? | ||
do { | ||
otherResults = try [score, score2].saveAll() | ||
} catch { | ||
otherResults = nil | ||
fatalError("Error saving: \(error)") | ||
} | ||
assert(otherResults != nil) | ||
|
||
otherResults!.forEach { result in | ||
switch result { | ||
case .success(let savedScore): | ||
print("Saved \"\(savedScore.className)\" with score \(savedScore.score) successfully") | ||
case .failure(let error): | ||
assertionFailure("Error saving: \(error)") | ||
} | ||
} | ||
|
||
PlaygroundPage.current.finishExecution() | ||
|
||
//: [Next](@next) |
59 changes: 0 additions & 59 deletions
59
ParseSwift.playground/Pages/1- Your first Object.xcplaygroundpage/Contents.swift
This file was deleted.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
ParseSwift.playground/Pages/2 - Finding Objects.xcplaygroundpage/Contents.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
//: [Previous](@previous) | ||
|
||
import PlaygroundSupport | ||
import Foundation | ||
import ParseSwift | ||
PlaygroundPage.current.needsIndefiniteExecution = true | ||
|
||
initializeParse() | ||
|
||
struct GameScore: ParseObject { | ||
var objectId: String? | ||
var createdAt: Date? | ||
var updatedAt: Date? | ||
var ACL: ParseACL? | ||
|
||
var score: Int? | ||
} | ||
|
||
var score = GameScore() | ||
score.score = 200 | ||
try score.save() | ||
|
||
let afterDate = Date().addingTimeInterval(-300) | ||
var query = GameScore.query("score" > 100, "createdAt" > afterDate) | ||
|
||
// Query asynchronously (preferred way) - Performs work on background | ||
// queue and returns to designated on designated callbackQueue. | ||
// If no callbackQueue is specified it returns to main queue | ||
query.limit(2).find(callbackQueue: .main) { results in | ||
switch results { | ||
case .success(let scores): | ||
|
||
assert(scores.count >= 1) | ||
scores.forEach { (score) in | ||
guard let createdAt = score.createdAt else { fatalError() } | ||
assert(createdAt.timeIntervalSince1970 > afterDate.timeIntervalSince1970, "date should be ok") | ||
} | ||
|
||
case .failure(let error): | ||
assertionFailure("Error querying: \(error)") | ||
} | ||
} | ||
|
||
// Query synchronously (not preferred - all operations on main queue) | ||
let results = try query.limit(2).find() | ||
assert(results.count >= 1) | ||
results.forEach { (score) in | ||
guard let createdAt = score.createdAt else { fatalError() } | ||
assert(createdAt.timeIntervalSince1970 > afterDate.timeIntervalSince1970, "date should be ok") | ||
} | ||
|
||
PlaygroundPage.current.finishExecution() | ||
|
||
//: [Next](@next) |
34 changes: 0 additions & 34 deletions
34
ParseSwift.playground/Pages/2- Finding Objects.xcplaygroundpage/Contents.swift
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.