Hi folks ! I'm using the library for KMP. I'm impl...
# supabase-kt
m
Hi folks ! I'm using the library for KMP. I'm implementing the Spotify login and i get directed to the webpage, do the log in and then the dialog "Open in <MyApp>" and get redirected to my app. The thing is that the session is not updated and i'm not getting any change on it. What I'm getting is the scene callback witht the access and refresh tokens. Is it supposed to update the session automatically or I should do anything else ? Thanks in advance ❤️
j
I assume this is on Kotlin/JS?
m
Yeah, i use kotlin multiplatform, but the callback is in swift
j
So the problem with the session not updating is in your iOS app?
m
Yesh, but i trigger everything from kotlin
j
Are you using deeplinks/url schemes? And have you read through this?
m
hhmmmm didn't find this before. So apart from the KMP library I should also import the iOs native library in order to call this from swift ? Thank you so much !!!!
j
No problem. > should also import the iOs native library in order to call this from swift ? No, only use one of them, they are not compatible.
m
then how I call
supabase.handleDeeplinks(url)
from my Swift code, supabase doesn't exists
j
You can call Kotlin code from Swift, but obviously you have to get the Supabase instance somehow. Do you use Dependency Injection or something like that? You can try to look at the chat demo, however this one is not using deeplinks.
This is the DI library used for the demo: https://insert-koin.io/docs/reference/koin-mp/kmp
And here is some information about swift interop: https://kotlinlang.org/docs/native-objc-interop.html
m
The problem is that I can't fin the method "handleDeeplinks()", is it inside SupabaseClient class ? Can't find it in mine.
thank you so much for your quick answer
j
m
AAAAAAAHHHH I get it now !! so i should do an expect/actual fun to access to this method right ? what I'm trying to figure out is how to pass each custom element, should I do a expect/actual fun for each platform or i can help with the a Singleton and set the URLS or Intent and then trigger the expect fun ? Would be good to have this is the docs maybe, I felt a bit lost at some point. Thank you so much, u made my day ❤️
j
so i should do an expect/actual fun to access to this method right
Yea thats the idea for Kotlin MP, you have platform specific implementations for some methods. You might some swift code anyways.
Would be good to have this is the docs maybe, I felt a bit lost at some point
Yea Kotlin MP can be confusing sometimes, I can only really refer to the Kotlin docs
m
Alright, have everything implemented and I receive the correct url data from swift, but seems that the Session still haven't succeed and the callback of onSessionSuccess is never called. I don't know what i could be missing this seems pretty simple hahaha
j
and you set the right host & scheme in the AuthConfig? If you set the log level to debug you might also see some logs (in the SupabaseClientBuilder)
The method does some checks to assure there is really a session
m
man I owe you a big coffee, problem solved !
j
Great, let me know if you have any questions!
f
i'm experiencing the same issue. i am not sure how to call the supabase.handleDeeplinks from the ios. i am using koin for di. @Jan @Marc Planas could you maybe provide a gist or sample? thanks in advance.
j
When the app
application
function is called, so that you can use the incoming url as the parameter. Apple documentation
j
Hey y'all, I am working on solving the same issues as mentioned in this thread where I am trying to use supabase google sign-in in a compose multiplatform app. The native google oauth works great but the iOS side is not working with the fallback google sign-in method. I think I also need to handle the deeplink when logging in and am not sure how to access the
SupabaseClient.handleDeeplinks(url)
on iOS.
Here is my current swift code. I am also using Koin for di so I created the following provider to access my client in Swift
Copy code
object DependencyProvider : KoinComponent {
    fun provideSupabaseClient() : SupabaseClient = get()
}
Then, I am tryin got use this to handle the deeplinks. If anyone has any suggestions that would be greatly appreciated (especially @F and @Jan who were talking about it last)!
j
Sorry for the late reply, @Josh Bogin:
Copy code
client.handleDeeplinks()
is an extension function, so something like this would work if calling from Swift directly:
Copy code
AppleKt.handleDeeplinks(supabaseClient, url, lambdaParam)
Not sure what type the third parameter is because it's an optional lambda parameter in Kotlin
j
Hmm I tried this in the swift code but it is saying
Cannot find 'AppleKt' in scope
for some reason. I have
*import* ComposeApp
at the top already too to provide access to the common code
I also tried passing it to the Kotlin code to use the extension in iOS main and then pass it through from the
ContentView
but I also got stuck with this approach bc I'm not sure how to use the
updateUIViewController
method to pass the deeplink to the
MainViewController