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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Add the package to your `Package.swift` dependencies:

```swift
dependencies: [
.package(url: "git@github.com:appwrite/sdk-for-apple.git", from: "4.0.0"),
.package(url: "git@github.com:appwrite/sdk-for-apple.git", from: "4.0.1"),
],
```

Expand Down
7 changes: 5 additions & 2 deletions Sources/Appwrite/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ open class Client {
"x-sdk-name": "Apple",
"x-sdk-platform": "client",
"x-sdk-language": "apple",
"x-sdk-version": "4.0.0",
"x-sdk-version": "4.0.1",
"X-Appwrite-Response-Format": "1.4.0"
]

Expand Down Expand Up @@ -321,18 +321,21 @@ open class Client {
default:
var message = ""
var data = try await response.body.collect(upTo: Int.max)
var type = ""

do {
let dict = try JSONSerialization.jsonObject(with: data) as? [String: Any]

message = dict?["message"] as? String ?? response.status.reasonPhrase
type = dict?["type"] as? String ?? ""
} catch {
message = data.readString(length: data.readableBytes)!
}

throw AppwriteError(
message: message,
code: Int(response.status.code)
code: Int(response.status.code),
type: type
)
}
}
Expand Down
11 changes: 5 additions & 6 deletions Sources/Appwrite/Services/Account.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ open class Account: Service {
success: String? = nil,
failure: String? = nil,
scopes: [String]? = nil
) throws -> Bool {
) async throws -> Bool {
let apiPath: String = "/account/sessions/oauth2/{provider}"
.replacingOccurrences(of: "{provider}", with: provider)

Expand All @@ -1017,13 +1017,12 @@ open class Account: Service {
let query = "?\(client.parametersToQueryString(params: apiParams))"
let url = URL(string: client.endPoint + apiPath + query)!
let callbackScheme = "appwrite-callback-\(client.config["project"] ?? "")"
let group = DispatchGroup()

group.enter()
WebAuthComponent.authenticate(url: url, callbackScheme: callbackScheme) { result in
group.leave()
try await withCheckedThrowingContinuation { continuation in
WebAuthComponent.authenticate(url: url, callbackScheme: callbackScheme) { result in
continuation.resume(with: result)
}
}
group.wait()

return true

Expand Down