Skip to content

Commit 60bb42e

Browse files
committed
Fix oauth XPC interrupt
1 parent 978e878 commit 60bb42e

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Add the package to your `Package.swift` dependencies:
3131

3232
```swift
3333
dependencies: [
34-
.package(url: "[email protected]:appwrite/sdk-for-apple.git", from: "4.0.0"),
34+
.package(url: "[email protected]:appwrite/sdk-for-apple.git", from: "4.0.1"),
3535
],
3636
```
3737

Sources/Appwrite/Client.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ open class Client {
2323
"x-sdk-name": "Apple",
2424
"x-sdk-platform": "client",
2525
"x-sdk-language": "apple",
26-
"x-sdk-version": "4.0.0",
26+
"x-sdk-version": "4.0.1",
2727
"X-Appwrite-Response-Format": "1.4.0"
2828
]
2929

@@ -321,18 +321,21 @@ open class Client {
321321
default:
322322
var message = ""
323323
var data = try await response.body.collect(upTo: Int.max)
324+
var type = ""
324325

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

328329
message = dict?["message"] as? String ?? response.status.reasonPhrase
330+
type = dict?["type"] as? String ?? ""
329331
} catch {
330332
message = data.readString(length: data.readableBytes)!
331333
}
332334

333335
throw AppwriteError(
334336
message: message,
335-
code: Int(response.status.code)
337+
code: Int(response.status.code),
338+
type: type
336339
)
337340
}
338341
}

Sources/Appwrite/Services/Account.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ open class Account: Service {
10031003
success: String? = nil,
10041004
failure: String? = nil,
10051005
scopes: [String]? = nil
1006-
) throws -> Bool {
1006+
) async throws -> Bool {
10071007
let apiPath: String = "/account/sessions/oauth2/{provider}"
10081008
.replacingOccurrences(of: "{provider}", with: provider)
10091009

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

1022-
group.enter()
1023-
WebAuthComponent.authenticate(url: url, callbackScheme: callbackScheme) { result in
1024-
group.leave()
1021+
try await withCheckedThrowingContinuation { continuation in
1022+
WebAuthComponent.authenticate(url: url, callbackScheme: callbackScheme) { result in
1023+
continuation.resume(with: result)
1024+
}
10251025
}
1026-
group.wait()
10271026

10281027
return true
10291028

0 commit comments

Comments
 (0)