llfbandit / app_links

Android App Links, Deep Links, iOs Universal Links and Custom URL schemes handler for Flutter.
https://pub.dev/packages/app_links
Apache License 2.0
176 stars 68 forks source link

iOS universal links are working only with Safari default browser #90

Closed AlexPopaUpcode closed 5 months ago

AlexPopaUpcode commented 5 months ago

Describe the bug

We have an app that has both a web and a mobile version. After registration the user receives a URL via email that will verify the email and auto login the user. We want to achieve the following: if user doesn't have the app installed then he will continue to the onboarding on the web app, but if the mobile app is already installed then we want to auto login the user and continue there.

On iOS the universal links are working only if the default browser is set to Safari and the user chooses the default browser to open the link. If user chooses another browser from the list, or the default browser is chrome, then the flow will continue in the web app instead to the mobile app.

Note that there is a redirect going on. When user taps on URL received via email, the browser opens, a request is sent to the backend to mark the registration completed (to confirm the email), then a redirect is performed. In the new redirect there is the universal link we want to capture.

Screenshot 2024-01-15 at 10 55 30

Does it related to

[ ] App Links (Android)
[ ] Deep Links (Android)
[x] Universal Links (iOS)
[ ] or Custom URL schemes? (iOS)

Does the example project work?

[ ] Yes
[ ] No
[x] Irrelevant here

Did you fully read the instructions for the targeted platform before submitting this issue?

Uploaded your files to webserver, HTTPS, direct connection, scheme pattern setup, ...

[x] Yes
[ ] No
[ ] Irrelevant here

AppDelegate.swift

import UIKit
import Flutter
import app_links

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate
    GeneratedPluginRegistrant.register(with: self)
    super.application(application, didFinishLaunchingWithOptions: launchOptions)
     if let url = AppLinks.shared.getLink(launchOptions: launchOptions) {
       AppLinks.shared.handleLink(url: url)
     }

     return false
  }
}
llfbandit commented 5 months ago

This package has no direct relation with web browsers. Are you sure that you're chrome browser has been setup to open links with applications? (I don't use Chrome, but on Firefox there's such of preference)

AlexPopaUpcode commented 5 months ago

I believe there is no such setup there. In Safari browser tap and hold on a URL shows more options, 2 of them are: Open in Safari and Open in MobileAppName. Pressing the Open in MobileAppName opens the mobile app, but pressing first one will open the URL in browser and not the mobile. Maybe this is because of user choice, but I want the default behaviour to be Open in mobile app instead of browser

llfbandit commented 5 months ago

There is nothing we can do here. This is external to this package even to your app...

AlexPopaUpcode commented 5 months ago

Thank you for responses!