auto_route_library icon indicating copy to clipboard operation
auto_route_library copied to clipboard

DeepLink Not Triggered When App is in Foreground

Open Adwaithnow opened this issue 1 year ago • 18 comments

auto_route version : 7.8.3 Describe the bug:

When attempting to use deep linking with auto_route, the specified URL from the deep link builder does not open when the app is in the foreground. However, the link works as expected when the app is in the closed state.

To Reproduce:

  1. Bring the app to the foreground (app should not be in the closed state).
  2. Execute the following ADB command to test deep linking:

adb shell 'am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d https://example.in/otherprofile/adwaith#4497"' in.adwaith.now

  1. Observe that the app does not respond to the deep link.

Expected behavior:

  1. The app should open the specified URL regardless of whether it's in the foreground or the closed state.
  2. If I am in the OtherProfileScreen for user 'abcd' and I click on a URL for another user, it should refresh the OtherProfileScreen with the correct username.

Code Snippet:

Here is my deepLinkBuilder function:

dart

FutureOr<DeepLink> deepLinkBuilder(PlatformDeepLink? deepLink) {
  if (deepLink?.path == '/') {
    return DeepLink.defaultPath;
  } else if (deepLink?.path.startsWith('/otherprofile') ?? false) {
    String? path =
        deepLink?.path.split('/otherprofile/')[1].replaceFirst('-', '#');
    return DeepLink([
      MainScreen(children: [
        HomeRoute(children: [OtherProfileScreen(username: path ?? '')])
      ])
    ]);
  }
  return DeepLink.defaultPath;
}

Additional context:

Currently, I am using a separate screen for debugging. I would appreciate any suggestions or best practices for debugging deep linking with auto_route.

Flutter 3.13.2 • channel stable Framework • revision ff5b5b5fa6 (12 days ago) • 2023-08-24 08:12:28 -0500 Engine • revision b20183e040 Tools • Dart 3.1.0 • DevTools 2.25.0

Adwaithnow avatar Sep 05 '23 16:09 Adwaithnow

I have this problem - deepLinkBuilder not triggered at all by deeplink!

Pavel-dnipro avatar Sep 15 '23 08:09 Pavel-dnipro

@Pavel-dnipro Did you find any solution?

JohannDesobry avatar Sep 28 '23 13:09 JohannDesobry

same here

daviresio avatar Oct 02 '23 23:10 daviresio

I have this problem - deepLinkBuilder not triggered at all by deeplink!

I as well had the Issue of only the app opening but not navigating and not even triggering the deeplinkBuilder. Only on iOS though. All was working fine if set up in a new Project referring to the cookbook. So my last resort was removing the whole ios project and add it new and fresh to the Project. That worked! Just had to setup all my tweaks and settings again 🙄... The Problem seemed to stem from the project.pbxproj file.

salbani avatar Nov 09 '23 11:11 salbani

@Milad-Akarie any progress for this issue ?

shahmirzali49 avatar Nov 24 '23 21:11 shahmirzali49

same here.

when app is terminated, deepLinkHandler callback works, but foreground or background(not task killed), deepLinkHandler ONLY works root path / only.

gothedistance avatar Feb 16 '24 09:02 gothedistance

Having the same issue in Android, everything works when the app is killed. If I put the back just in background, the deep link builder is not triggered, it doesn't navigate to the route. Any updates on this?

alexanderkorus-oskar avatar Apr 25 '24 12:04 alexanderkorus-oskar