Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add experimental support for IOS native target #53

Merged
merged 7 commits into from
Apr 6, 2023
Merged

Conversation

jan-tennert
Copy link
Collaborator

@jan-tennert jan-tennert commented Feb 1, 2023

What kind of change does this PR introduce?

Feature

What is the current behavior?

No support for IOS

What is the new behavior?

Support for iosArm64, iosSimulatorArm64, and iosX64 including deeplinking (syntax same as android)

Additional context

I cannot really test this PR as I don't have Mac myself to run a IOS Emulator on. I'm also not really familiar with IOS programming. Help would be appreciated

If you want to help, there is a version supporting IOS: 0.8.5-ios

Currently needed: Feedback for deeplinking

To enable deeplinking, setup an URL Scheme
and set the host & scheme in the gotrue plugin:

install(GoTrue) {
    scheme = "supacompose"
    host = "login"
}

And on startup, call client.handleDeeplinks(url)

@jan-tennert jan-tennert added enhancement New feature or request help wanted Extra attention is needed labels Feb 1, 2023
@jan-tennert jan-tennert added this to the 0.8.0 milestone Feb 1, 2023
@jan-tennert jan-tennert self-assigned this Feb 1, 2023
@jan-tennert jan-tennert changed the base branch from master to 0.8.0 February 1, 2023 14:45
@jan-tennert jan-tennert modified the milestones: 0.8.0, 0.9.0 Feb 1, 2023
@jan-tennert jan-tennert removed this from the 0.9.0 milestone Feb 8, 2023
@jan-tennert jan-tennert changed the base branch from development to master February 9, 2023 19:23
@jan-tennert
Copy link
Collaborator Author

Published a version (0.8.0-beta-2-ios) with support for IOS, testing would be appreciated! If you also can test deep linking, the syntax is the same as Android but with URL Schemes

@jollygreenegiant
Copy link
Contributor

For what it's worth, I've been testing this a bit in my own app and have not had any issues on the iOS side - things look great. Haven't had the chance to test deep linking though

@jan-tennert
Copy link
Collaborator Author

For what it's worth, I've been testing this a bit in my own app and have not had any issues on the iOS side - things look great. Haven't had the chance to test deep linking though

Great! Once the deep linking is settled, I'll merge this PR. I'm unsure about one thing: On Android supabase-kt pause and resumes auto refresh for the GoTrue session. Should this also be done on IOS/how would one implement this on IOS (using Kotlin of course)?

@seankcw
Copy link

seankcw commented Mar 15, 2023

@jan-tennert could you please add the support for Arm64 simulator targets?
Related:

image

@jan-tennert
Copy link
Collaborator Author

I'm not able to call the api that required bearer token (e.g. retrieveUserForCurrentSession(), refreshCurrentSession()..), somehow it will send two tokens in Authorization header. Is it a bug?

Screenshot 2023-03-24 at 10 04 14 AM

Yes that was indeed a bug, ktor was adding an access token twice. Should be fixed in version 0.8.5-ios

@jan-tennert
Copy link
Collaborator Author

@seankcw @jollygreenegiant Did anyone get the chance to test out deeplinking?

@seankcw
Copy link

seankcw commented Apr 6, 2023

@jan-tennert I tested 0.8.5 I can successfully log in with my account, but I haven't tested the deep linking on client-side project, because I'm doing deeplink/token verification in KMM directly (with MVI pattern).
I think the current version is still good to go.

@jan-tennert jan-tennert marked this pull request as ready for review April 6, 2023 11:35
@jan-tennert
Copy link
Collaborator Author

@jan-tennert I tested 0.8.5 I can successfully log in with my account, but I haven't tested the deep linking on client-side project, because I'm doing deeplink/token verification in KMM directly (with MVI pattern). I think the current version is still good to go.

Alright, thanks! Then I'll merge this PR for now

@jan-tennert jan-tennert changed the base branch from master to development April 6, 2023 11:35
@ldobransky
Copy link

ldobransky commented Apr 26, 2023

I was testing it, but when deeplink is handled, in URL object are data, but method handleDeeplink don't save data. When I am calling supabaseClient.gotrue.currentAccessTokenOrNull() I am getting null.
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool { SupaBaseHelper().handleDeeplinks(url: url) return true }
in handleDeeplinks I am calling supabaseClient.handleDeeplinks(url)
supabaseClient is shared from DI by Koin.

on Android is working well.
can somebody help me? I am using version 0.9.3.

@jan-tennert
Copy link
Collaborator Author

jan-tennert commented Apr 26, 2023

I was testing it, but when deeplink is handled, in URL object are data, but method handleDeeplink don't save data. When I am calling supabaseClient.gotrue.currentAccessTokenOrNull() I am getting null.
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool { SupaBaseHelper().handleDeeplinks(url: url) return true }
in handleDeeplinks I am calling supabaseClient.handleDeeplinks(url)
supabaseClient is shared from DI by Koin.

on Android is working well.
can somebody help me? I am using version 0.9.3.

Couldnt test out deeplinking as I stated. Can you print out url.fragment and show me how it looks like? (dont show the access token if there is one)

@ldobransky
Copy link

here is output from fragment.url print:
Optional("access_token={access_token}&expires_in=3600&provider_token={provider_token}&refresh_token={refresh_token}&token_type=bearer")
values in {} was changed, there was tokens.

@jan-tennert
Copy link
Collaborator Author

here is output from fragment.url print: Optional("access_token={access_token}&expires_in=3600&provider_token={provider_token}&refresh_token={refresh_token}&token_type=bearer") values in {} was changed, there was tokens.

Okay that looks alright, I published a dev version 0.9.4-dev-1 with further logging and changes. Can you enable logging and show what is says?

@ldobransky
Copy link

I added 0.9.4-dev-1 logs bellow:
💚 DEBUG OAuthProvider.openOAuthlambda - Successfully opened provider url in safari 💚 DEBUG SupabaseClient - Received deeplink with wrong scheme or host
between those two debug logs are mine what is mentioned above

@jan-tennert
Copy link
Collaborator Author

I added 0.9.4-dev-1 logs bellow: 💚 DEBUG OAuthProvider.openOAuthlambda - Successfully opened provider url in safari 💚 DEBUG SupabaseClient - Received deeplink with wrong scheme or host between those two debug logs are mine what is mentioned above

Okay so you can try to print out url.scheme and url.host and check if it matches with your GoTrue configuration? GoTrue checks if the received deeplink host & scheme matches with the provided one in the config:

if(url.scheme != gotrue.config.scheme || url.host != gotrue.config.host){
Napier.d { "Received deeplink with wrong scheme or host" }
return
}

@ldobransky
Copy link

ok, you have right, I had wrong configuration in GoTrue, I changed it for correct one, but I am getting exception right now.
KtorSupabaseHttpClient.request[async] - Request failed with TLS sessions are not supported on Native platform. Uncaught Kotlin exception: io.github.jan.supabase.exceptions.HttpRequestException: HTTP request to http://localhost (GET) failed with message: TLS sessions are not supported on Native platform. I think I had same exception when I was trying Email authentication, but on Android works both well. I have issue only for iOS

@jan-tennert
Copy link
Collaborator Author

jan-tennert commented Apr 26, 2023

ok, you have right, I had wrong configuration in GoTrue, I changed it for correct one, but I am getting exception right now.
KtorSupabaseHttpClient.request[async] - Request failed with TLS sessions are not supported on Native platform. Uncaught Kotlin exception: io.github.jan.supabase.exceptions.HttpRequestException: HTTP request to http://localhost (GET) failed with message: TLS sessions are not supported on Native platform. I think I had same exception when I was trying Email authentication, but on Android works both well. I have issue only for iOS

are you using the darwin ktor engine for ios? If not, try it

@ldobransky
Copy link

really thanks for help, it helped :)

@jan-tennert
Copy link
Collaborator Author

really thanks for help, it helped :)

No problem! I'll add additional information to the troubleshooting page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants