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

Deeplink URL scheme should also include domain name (iOS and Android) #100624

Closed
3 tasks done
naamapps opened this issue Mar 23, 2022 · 19 comments
Closed
3 tasks done

Deeplink URL scheme should also include domain name (iOS and Android) #100624

naamapps opened this issue Mar 23, 2022 · 19 comments
Assignees
Labels
f: routes Navigator, Router, and related APIs. found in release: 2.10 Found to occur in 2.10 found in release: 2.13 Found to occur in 2.13 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list

Comments

@naamapps
Copy link

naamapps commented Mar 23, 2022

Steps to Reproduce

Setup url scheme for both ios and android, on android without the host data and on ios like normal:
Android:

  <intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="somescheme" />
  </intent-filter>

ios:

	<array>
		<dict>
			<key>CFBundleTypeRole</key>
			<string>Editor</string>
			<key>CFBundleURLName</key>
			<string>com.scheme.app</string>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>somescheme</string>
			</array>
		</dict>
	</array>

After setup, try to launch the app on both platform with the scheme like this:
somescheme://search

You'll see that the search part is ignored.
If we try to launch the app like this:
somescheme://blabla/search
It will work!

Expected results: URL schemes should work out of the box with no issues, without ignoring the first URL section.

Actual results: Flutter ignores the first URL section when launching the app from a url scheme.

Flutter doctor
[✓] Flutter (Channel stable, 2.10.3, on macOS 12.2.1 21D62 darwin-x64, locale en-IL)
    • Flutter version 2.10.3 at /Users/naamapps/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7e9793dee1 (3 weeks ago), 2022-03-02 11:23:12 -0600
    • Engine revision bd539267b4
    • Dart version 2.16.1
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/naamapps/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)

[✓] VS Code (version 1.65.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.36.0

[✓] Connected device (2 available)
    • SM G998B (mobile) • R5CR214C1LM • android-arm64  • Android 12 (API 31)
    • Chrome (web)      • chrome      • web-javascript • Google Chrome 99.0.4844.83

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

This will be done in series of three prs:

@maheshmnj maheshmnj added the in triage Presently being triaged by the triage team label Mar 24, 2022
@maheshmnj
Copy link
Member

maheshmnj commented Mar 24, 2022

Hi @naamapps, Thanks for filing the issue. I am quite not sure I understood the issue, When I configure the deeplink I am able to launch the app.

adb shell am start -a android.intent.action.VIEW \
    -c android.intent.category.BROWSABLE \
    -d "somescheme://blabala/search"

You'll see that the search part is ignored. If we try to launch the app like this: somescheme://blabla/search

Could you please clarify what exactly you meant by this? Do you mean /search is not shown in the captured link?
if so, Can you please share the minimal and complete code sample along with the output of flutter doctor -v?

@maheshmnj maheshmnj added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Mar 24, 2022
@naamapps
Copy link
Author

Hey sorry for the confusion.
What I mean is that the blabla is ignored so the search is used.
But if only search is used, then the launched route will empty.

It is launching the app on both cases but the route is not correct.

somescheme://search - launches the app but the 'search' is ignored, so the search route is not the first route.

somescheme://blabla/search - launches the app and directs to the correct search route. (so the blabla is ignored, and only the second section is being used to determine the initial route of the app).

Hope it's clearer

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Mar 24, 2022
@maheshmnj
Copy link
Member

maheshmnj commented Mar 24, 2022

Thanks for the clarification @naamapps, Could you please share a minimal reproducible code sample that shows the route path is incorrectly fetched?

@maheshmnj maheshmnj added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Mar 24, 2022
@naamapps
Copy link
Author

Put this in your main.dart.
and then run the adb command you sent earlier, and you'll see that if you run somescheme://blabala/search only /search will show up and not the full url with the blabla.

And if you run somescheme://search, you'll see only / as the route!

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      onGenerateRoute: (settings) {
        return MaterialPageRoute(builder: (_) {
          return BugPage(path: settings.name ?? "Unknown route");
        });
      },
      title: 'Bug',
    );
  }
}

class BugPage extends StatefulWidget {
  final String path;
  const BugPage({Key? key, required this.path}) : super(key: key);

  @override
  State<BugPage> createState() => _BugPageState();
}

class _BugPageState extends State<BugPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Text("path: " + widget.path),
      ),
    );
  }
}

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Mar 27, 2022
@maheshmnj
Copy link
Member

maheshmnj commented Mar 28, 2022

Thanks for the code sample @naamapps, I am seeing a different behavior on Android

somescheme://blabla/search launches / on Android and /search on IOS

somescheme://search launches / on Android and '' on IOS

AndroidManifest.xml

<intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="somescheme" android:host = "" />
            </intent-filter>

Info.plist

<key>FlutterDeepLinkingEnabled</key>
	<true/>
    <key>CFBundleURLTypes</key>
	<array>
		<dict>
			<key>CFBundleTypeRole</key>
			<string>Editor</string>
			<key>CFBundleURLName</key>
			<string>com.scheme.app</string>
			<key>CFBundleURLSchemes</key>
			<array>
			<string>somescheme</string>
			</array>
		</dict>
         </array>	
flutter doctor -v (mac)
[✓] Flutter (Channel stable, 2.10.3, on macOS 12.1 21C52 darwin-arm, locale en-GB)
    • Flutter version 2.10.3 at /Users/mahesh/Documents/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 7e9793dee1 (20 hours ago), 2022-03-02 11:23:12 -0600
    • Engine revision bd539267b4
    • Dart version 2.16.1
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/mahesh/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.10.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)

[✓] IntelliJ IDEA Community Edition (version 2021.2.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 61.2.4
    • Dart plugin version 212.5080.8

[✓] VS Code (version 1.63.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.36.0

[✓] Connected device (3 available)
    • Redmi K20 Pro (mobile) • 192.168.1.5:5555 • android-arm64  • Android 11 (API 30)
    • macOS (desktop)        • macos            • darwin-arm64   • macOS 12.1 21C52 darwin-arm
    • Chrome (web)           • chrome           • web-javascript • Google Chrome 99.0.4844.51

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

@maheshmnj maheshmnj added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Mar 28, 2022
@naamapps
Copy link
Author

@maheshmnj
Remove the android:host from android manifest. Only provide the scheme like I mentioned in the original message.

But either way, we can clearly see that something is not working here.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Mar 28, 2022
@maheshmnj
Copy link
Member

@naamapps sorry about that, Please ignore the host I accidentally added it. Even without the host with the below Intent-filters

<intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="somescheme"/>
            </intent-filter>

Running

adb shell am start -a android.intent.action.VIEW \
    -c android.intent.category.BROWSABLE -d "somescheme://blabla/search"

still returns /

Could you please reconfirm if you are seeing the same behavior on Android?

@maheshmnj maheshmnj added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Mar 28, 2022
@naamapps
Copy link
Author

I do not, I see /search.
Did you add this also to the manifest?
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Mar 28, 2022
@maheshmnj
Copy link
Member

maheshmnj commented Mar 28, 2022

Did you add this also to the manifest?

Sorry about that, I missed that part now I am able to reproduce the same behavior as you.

somescheme://blabla/ => launches /
somescheme://blabla/search => launches /search
somescheme://blabla/search/route => launches /search/route

I believe it is working as intended since anything that follows "//" will be part of the hostname so "blabla" in the above case won't be returned. Labeling this issue for further investigation from the team.

code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      onGenerateRoute: (settings) {
        return MaterialPageRoute(builder: (_) {
          return BugPage(path: settings.name ?? "Unknown route");
        });
      },
      title: 'Bug',
    );
  }
}

class BugPage extends StatefulWidget {
  final String path;
  const BugPage({Key? key, required this.path}) : super(key: key);

  @override
  State<BugPage> createState() => _BugPageState();
}

class _BugPageState extends State<BugPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Text("path: " + widget.path),
      ),
    );
  }
}
flutter doctor -v (mac)
[✓] Flutter (Channel stable, 2.10.4, on macOS 12.3 21E230 darwin-arm, locale en-GB)
    • Flutter version 2.10.4 at /Users/mahesh/Documents/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c860cba910 (3 days ago), 2022-03-25 00:23:12 -0500
    • Engine revision 57d3bac3dd
    • Dart version 2.16.2
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/mahesh/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.10.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)

[✓] IntelliJ IDEA Community Edition (version 2021.2.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 61.2.4
    • Dart plugin version 212.5080.8

[✓] VS Code (version 1.65.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.37.20220301

[✓] Connected device (4 available)
    • Redmi K20 Pro (mobile) • 192.168.1.2:55555                    • android-arm64  • Android 11 (API 30)
    • iPhone 12 Pro (mobile) • 535317A4-921C-488F-B234-C2CC6D4AE5A1 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
    • macOS (desktop)        • macos                                • darwin-arm64   • macOS 12.3 21E230 darwin-arm
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 99.0.4844.83

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
[✓] Flutter (Channel master, 2.13.0-0.0.pre.277, on macOS 12.3 21E230 darwin-arm, locale en-GB)
    • Flutter version 2.13.0-0.0.pre.277 at /Users/mahesh/Documents/flutter_master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 13d2381109 (6 hours ago), 2022-03-27 21:00:08 -0400
    • Engine revision 559e259c54
    • Dart version 2.17.0 (build 2.17.0-246.0.dev)
    • DevTools version 2.11.4

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/mahesh/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    ! CocoaPods 1.10.2 out of date (1.11.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin
        usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)

[✓] IntelliJ IDEA Community Edition (version 2021.2.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 61.2.4
    • Dart plugin version 212.5080.8

[✓] VS Code (version 1.65.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.37.20220301

[✓] Connected device (4 available)
    • Redmi K20 Pro (mobile) • 192.168.1.2:55555                    • android-arm64  • Android 11 (API 30)
    • iPhone 12 Pro (mobile) • 535317A4-921C-488F-B234-C2CC6D4AE5A1 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
    • macOS (desktop)        • macos                                • darwin-arm64   • macOS 12.3 21E230 darwin-arm
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 99.0.4844.83

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.

@maheshmnj maheshmnj added framework flutter/packages/flutter repository. See also f: labels. f: routes Navigator, Router, and related APIs. has reproducible steps The issue has been confirmed reproducible and is ready to work on found in release: 2.10 Found to occur in 2.10 found in release: 2.13 Found to occur in 2.13 and removed in triage Presently being triaged by the triage team labels Mar 28, 2022
@naamapps
Copy link
Author

I don't believe it's the intended behavior.
In ios there can't be an host when using a scheme and it's still missing the first section.
I believe that if there is a host - flutter needs to ignore the first section,
If the host is not included (ios, and host-less android scheme) - flutter should include the whole url.

It's 100% a bug

@goderbauer
Copy link
Member

@chunhtai

@goderbauer goderbauer added the P2 Important issues not at the top of the work list label Mar 30, 2022
@artahc
Copy link

artahc commented Aug 30, 2022

I'm also facing this issue, when configuring routes using go_router

When I launch myapp://mypage, the router is not pushing /mypage. I'm expecting the router should push /mypage

@chunhtai
Copy link
Contributor

The first part is domain name, and currently router only gets the path part plus query parameter and segment.

@KestasVenslauskas
Copy link

It it helps for anyone you can bypass the host by using only one slash after schema... For example myApp:/mypage... Still I also think it's a bug and it should be fixed to work as expected out of the box.

@chunhtai
Copy link
Contributor

This come up during the discussion for deeplink, this is currently blocking app to handle deeplink from different domain names

@chunhtai chunhtai changed the title Deeplink URL scheme ignores first url section (iOS and Android) Deeplink URL scheme should also include domain name (iOS and Android) Dec 12, 2022
@kuzawa
Copy link

kuzawa commented Jan 25, 2023

I am actually having trouble with this behavior as well.
This behavior is not what is expected with custom url schemes and ios.

@chunhtai chunhtai self-assigned this Feb 1, 2023
auto-submit bot pushed a commit that referenced this issue Apr 24, 2023
#119968)

Related #100624

The goal is to make sure the engine can send a location string in either the existing format or a complete uri string to the framework, and the framework will still work as usual.
auto-submit bot pushed a commit to flutter/engine that referenced this issue May 18, 2023
auto-submit bot pushed a commit to flutter/engine that referenced this issue May 18, 2023
@chunhtai
Copy link
Contributor

chunhtai commented Jun 8, 2023

Close as done

@chunhtai chunhtai closed this as completed Jun 8, 2023
@maRci002
Copy link
Contributor

maRci002 commented Jun 8, 2023

Thanks for finishing this issue.

I knew RouteInformation.location cannot be null which is mentioned by #116491

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
f: routes Navigator, Router, and related APIs. found in release: 2.10 Found to occur in 2.10 found in release: 2.13 Found to occur in 2.13 framework flutter/packages/flutter repository. See also f: labels. has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list
Projects
None yet
Development

No branches or pull requests

8 participants