Hi all. I am doing a project in Jetpack Compose Mu...
# multiplatform
s
Hi all. I am doing a project in Jetpack Compose Multiplatform. I need to implement google sign in on Android and iOS. Are there any libraries, any ideas how I can organize expect/actual interface for each platform?
k
JC for iOS is not even in technical preview, so I’m sure there are no libraries to handle this. I’m not sure what you’d want to be in the common code for this. A token? The user’s info? I assume the easiest would be to include the Google sign in components on each platform separately, and show them separately when needed, then store the necessary result in common storage.
s
Okay, do you think it's possible to use the ios implementation of google sign in in iosMain using kotlin?
l
The only bit of ‘code’ associated with Google Sign-On is the call to
Copy code
GIDSignIn.sharedInstance.handle(url)
in
application:openURL:options
for handling the redirect. You could set up an expect/actual for that one call. In terms of the UI, it depends on if you are using UIKit or SwiftUI. If using UIKit, you can handle the UIView in Kotlin code, but SwiftUI has to be done in Swift.
I guess you could also handle
restorePreviousSignInWithCallback
in Kotlin code, again with an expect/actual, but for that, it may be easier to make the call in Swift and write the logic for handling signed-in and signed-out state in Kotlin.
k
I would expect doing the iOS UI in Kotlin is going to be a lot more effort than it’s worth, but that’s up to you. As Landry’s saying, I’d just store shared, and personally I’d just write any native code that needs bridging with an interface and pass in an implementation from Swift on app start, rather than some kind of cinterop situation.