Skip to content

Commit 97fb0fe

Browse files
committed
feat: Update example app to use async/await and bump version to 2.1.0
1 parent 2bb6c46 commit 97fb0fe

File tree

5 files changed

+28
-17
lines changed

5 files changed

+28
-17
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## [2.1.0] 2025-12-04
4+
5+
* [Pull #330](https://github.com/uber/uber-ios-sdk/pull/330) Add async/await support for authentication methods
6+
37
## [0.14.0] 2023-04-18
48

59
* [Pull #278](https://github.com/uber/rides-ios-sdk/pull/278) Implementing PAR

Sources/UberAuth/Authorize/AuthorizationCodeAuthProvider.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public final class AuthorizationCodeAuthProvider: AuthProviding {
294294
let callbackURLScheme = callbackURL.scheme else {
295295
throw UberAuthError.invalidRequest("Invalid redirect URI")
296296
}
297-
#warning("Why we were passing a new instance of ASPresentationAnchor at 274?")
297+
298298
return try await withCheckedThrowingContinuation { continuation in
299299
if let sessionBuilder = authenticationSessionBuilder {
300300
currentSession = sessionBuilder(

Sources/UberCore/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>0.13.0</string>
18+
<string>2.1.0</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>NSPrincipalClass</key>

Sources/UberRides/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>0.13.0</string>
18+
<string>2.1.0</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

examples/UberSDK/UberSDK/ContentView.swift

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,24 @@ final class Content {
5454
var isPrefillExpanded: Bool = false
5555
var response: AuthReponse?
5656
var prefillBuilder = PrefillBuilder()
57+
var loginTask: Task<Void, Never>?
5758
var isLoggedIn: Bool {
5859
UberAuth.isLoggedIn
5960
}
6061

6162
func login() {
62-
63+
loginTask?.cancel()
64+
loginTask = Task {
65+
do {
66+
try await login()
67+
} catch {
68+
response = AuthReponse(value: error.localizedDescription)
69+
}
70+
loginTask = nil
71+
}
72+
}
73+
74+
private func login() async throws {
6375
var prompt: Prompt = []
6476
if shouldForceLogin { prompt.insert(.login) }
6577
if shouldForceConsent { prompt.insert(.consent) }
@@ -77,24 +89,15 @@ final class Content {
7789
}
7890
}()
7991

80-
UberAuth.login(
92+
let client = try await UberAuth.login(
8193
context: .init(
8294
authDestination: authDestination,
8395
authProvider: authProvider,
8496
prefill: isPrefillExpanded ? prefillBuilder.prefill : nil
85-
),
86-
completion: { result in
87-
// Slight delay to allow for ASWebAuthenticationSession dismissal
88-
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
89-
switch result {
90-
case .success(let client):
91-
self.response = AuthReponse(value: "\(client)")
92-
case .failure(let error):
93-
self.response = AuthReponse(value: error.localizedDescription)
94-
}
95-
}
96-
}
97+
)
9798
)
99+
100+
response = AuthReponse(value: "\(client)")
98101
}
99102

100103
func logout() {
@@ -106,6 +109,10 @@ final class Content {
106109
UberAuth.handle(url)
107110
}
108111

112+
deinit {
113+
loginTask?.cancel()
114+
}
115+
109116
enum Item: String, Hashable, Identifiable {
110117
case type = "Auth Type"
111118
case destination = "Destination"

0 commit comments

Comments
 (0)