Skip to content

Commit 39d3e70

Browse files
committed
fix(expo): add iOS getClientToken bridge method and pass keychain config to Clerk.configure
Restore the getClientToken bridge method on iOS so native-to-JS session sync works after native sign-in (AuthView/InlineAuthView). Pass the resolved keychainService to Clerk.configure() via options so the native SDK uses the same keychain service as our helpers, supporting custom keychain services via ClerkKeychainService in Info.plist.
1 parent bdd15bd commit 39d3e70

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

packages/expo/ios/ClerkExpoModule.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public protocol ClerkViewFactoryProtocol {
2222
// SDK operations
2323
func configure(publishableKey: String, bearerToken: String?) async throws
2424
func getSession() async -> [String: Any]?
25+
func getClientToken() -> String?
2526
func signOut() async throws
2627
}
2728

@@ -170,6 +171,18 @@ class ClerkExpoModule: RCTEventEmitter {
170171
}
171172
}
172173

174+
// MARK: - getClientToken
175+
176+
@objc func getClientToken(_ resolve: @escaping RCTPromiseResolveBlock,
177+
reject: @escaping RCTPromiseRejectBlock) {
178+
guard let factory = clerkViewFactory else {
179+
resolve(nil)
180+
return
181+
}
182+
183+
resolve(factory.getClientToken())
184+
}
185+
173186
// MARK: - signOut
174187

175188
@objc func signOut(_ resolve: @escaping RCTPromiseResolveBlock,

packages/expo/ios/ClerkViewFactory.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@ public class ClerkViewFactory: ClerkViewFactoryProtocol {
6464
}
6565

6666
Self.clerkConfigured = true
67-
Clerk.configure(publishableKey: publishableKey)
67+
let options: Clerk.Options = if let service = Self.keychainService {
68+
.init(keychainConfig: .init(service: service))
69+
} else {
70+
.init()
71+
}
72+
Clerk.configure(publishableKey: publishableKey, options: options)
6873

6974
// Wait for Clerk to finish loading (cached data + API refresh).
7075
// The static configure() fires off async refreshes; poll until loaded.
@@ -200,6 +205,10 @@ public class ClerkViewFactory: ClerkViewFactoryProtocol {
200205
}
201206
}
202207

208+
public func getClientToken() -> String? {
209+
return Self.readNativeDeviceToken()
210+
}
211+
203212
public func createAuthViewController(
204213
mode: String,
205214
dismissable: Bool,

0 commit comments

Comments
 (0)