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

Unable to Capture Redirect URLs with 'http' or 'https' CallbackUrlScheme on iOS without user interaction #65

Open
2 tasks done
neokree opened this issue Sep 12, 2023 · 11 comments
Assignees
Labels
apple [See issue #68] Just Apple being Apple again... bug Something isn't working

Comments

@neokree
Copy link

neokree commented Sep 12, 2023

Describe the bug

When using this library with Universal Links on iOS to login into a service, the link is opened in the browser if the user is already logged in.

To Reproduce

Steps to reproduce the behavior:

  1. Setup Universal Links in example app and custom domain (and verify they are valid from iOS Settings -> Developer -> Universal Link)
  2. Edit the example app connection html page to include this snippet:
    <p>Redirecting in 3 seconds...</p>
    <script>
        setTimeout(function() {
            window.location.href = 'https://your.domain.com/?token=balalalala';
        }, 3000); // 3000 milliseconds = 3 seconds
    </script>
  1. Run the example app, try to login and wait for 3 seconds
  2. The universal link is opened inside the browser instead of returning to the app

Expected behavior

When using a redirect to a universal link without user interaction, browser closes and app receives the callback

Device (please complete the following information!)

  • Device: iPhone 11
  • OS: iOS 16.6
  • Browser: Safari
  • flutter_web_auth_2 version: 2.2.1

Additional context

This seems more like a bug of Safari, instead of this library's code (Read "Preparing Your App to Handle Universal Links" at https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html)
Nevertheless I have lost 2 days trying to fix it so it seemed logic to me that this situation must be shared for future developers.

Checklist

  • I have read and followed the entire troubleshooting guide and it has not provided the solution I need.
  • I have provided all the information I can (incl. auth URL etc.)
@neokree neokree added the bug Something isn't working label Sep 12, 2023
@ThexXTURBOXx ThexXTURBOXx added the apple [See issue #68] Just Apple being Apple again... label Sep 12, 2023
@rdunlocked18
Copy link

Any Update on this ?

@ThexXTURBOXx
Copy link
Owner

This looks like "Apple being Apple" again. I am unsure if this is a bug within this package or iOS or the backend since there is no way for me to test that (I don't own a apple device)

@rdunlocked18
Copy link

This looks like "Apple being Apple" again. I am unsure if this is a bug within this package or iOS or the backend since there is no way for me to test that (I don't own a Apple device)

I am not able to redirect to the application. I have no setup for Universal Links also I am using localhost:3000/callback.html as a redirect URL. If you want to test anything on iOS I can help.

Can you tell me what should be

  1. Redirect URL :
  2. Callback Scheme For ios :

Currently, it shows a white page if I redirect with code on localhost:3000/callback.html, should this page be live .. in the sense should it load?

@ThexXTURBOXx
Copy link
Owner

This is a case of "RTFM", but I will help anyway:
The redirect URL is the URL which serves the login page.
The callback scheme is the URL scheme that is used for redirection to the app.

@rdunlocked18
Copy link

This is a case of "RTFM", but I will help anyway: The redirect URL is the URL which serves the login page. The callback scheme is the URL scheme that is used for redirection to the app.

That thing is fine ! but what if I don't have universal links added ?

@ThexXTURBOXx
Copy link
Owner

ThexXTURBOXx commented Sep 20, 2023

This is the setup without universal links. If you want universal links, you need to some extra setup. Otherwise, everything works normally

Edit: Also, this issue is about universal links. If you have issues without them, you are better off filing a new issue

@SunilKividor
Copy link

@ThexXTURBOXx @rdunlocked18 Did you guys have any solution regrading redirection in IOS ?

@SunilKividor
Copy link

@ThexXTURBOXx I do not have the classes(FlutterWebAuth2Plugin.h,...) in my IOS folder. DO i need to add those three files too ?

@rdunlocked18
Copy link

Nothing just add the same URL scheme in iOS, which is of Android, and also in info.plist...Add this from below & change the URL Scheme

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>$(url schema)</string>
        </array>
    </dict>
</array>

@SunilKividor
Copy link

@rdunlocked18 Do i need to add the scheme in this way if it is https ? - $https

@SunilKividor
Copy link

@rdunlocked18 if i use https as my url scheme , does the redirect link should be of valid domain ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apple [See issue #68] Just Apple being Apple again... bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants