Hey Everyone, do you have any examples to implemen...
# multiplatform
p
Hey Everyone, do you have any examples to implement asynchrnous calls between swift and Kotlin? My usecase: I have a swiftView, written in swift (SignInWithAppleButton) which I am calling it in my compose screen(using swift-compose interop), now the sign in call is also present in the button itself(and its an asynchronous call), if sign in is success I can access a token id (String), I want to return this token id to my kotlin code so that I can do sign in using supabase This is the swift ui view , and I want to return the tokenId to my kotlin code instead of calling that client.auth.signInWithIdToken() here
SignInWithAppleButton { request in
request.requestedScopes = [.email, .fullName]
} onCompletion: { result in
Task {
do {
guard let credential = try result.get().credential as? ASAuthorizationAppleIDCredential
else {
return
}
guard let idToken = credential.identityToken
.flatMap({ String(data: $0, encoding: .utf8) })
else {
return
}
try await client.auth.signInWithIdToken(
credentials: .init(
provider: .apple,
idToken: idToken
)
)
} catch {
dump(error)
}
}
}
.fixedSize()
p
Declare a LoginCallback in commonMain and expose it to swift. It has to be public in your integration module. Then when the login completes call this interface functions from swift.