plus_plugins icon indicating copy to clipboard operation
plus_plugins copied to clipboard

[Bug]: The URI_INTENT_SCHEME of Android is not supported

Open fzdfy opened this issue 1 year ago • 4 comments

The url scheme for a third-party android app is 'intent://xxx', and AndroidIntent cannot open the app. but It can be opened this way in android native.

flutter: can't open

..setNavigationDelegate(NavigationDelegate(
    onNavigationRequest: (NavigationRequest request) async {
      final intent = AndroidIntent(
        action: 'action_view',
        data: Uri.encodeFull(request.url),
      );
      intent.launch();
 }

android: can open

intent = Intent.parseUri(request.getUrl().toString(), Intent.URI_INTENT_SCHEME);
startActivity(intent);

Platform

Android 11

Plugin

android_intent_plus

Version

4.0.2

Flutter SDK

=2.15.1 <3.0.0

Flutter Doctor

➜  ~ flutter doctor -v
[✓] Flutter (Channel stable, 3.10.6, on macOS 13.2.1 22D68 darwin-arm64, locale
    zh-Hans-BR)
    • Flutter version 3.10.6 on channel stable at
      /Users/fengyunpeng/Documents/work/luojing/flutter/sdk/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f468f3366c (3 months ago), 2023-07-12 15:19:05 -0700
    • Engine revision cdbeda788a
    • Dart version 3.0.6
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Users/fengyunpeng/Library/Android/sdk
    • Platform android-33, build-tools 30.0.3
    • ANDROID_HOME = /Users/fengyunpeng/Library/Android/sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14A400
    • CocoaPods version 1.12.1

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

[✓] Android Studio (version 2021.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.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Ultimate Edition (version 2021.3.2)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • 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

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

Checklist before submitting a bug

  • [X] I Google'd a solution and I couldn't find it
  • [X] I searched on StackOverflow for a solution and I couldn't find it
  • [X] I read the README.md file of the plugin
  • [X] I'm using the latest version of the plugin
  • [X] All dependencies are up to date with flutter pub upgrade
  • [X] I did a flutter clean
  • [X] I tried running the example project

fzdfy avatar Sep 28 '23 08:09 fzdfy

Does not support android intent:// scheme in a way that evokes third-party apps。

You need to explain it better as currently it is hard to understand what you want, not to mention that Logs section with completely irrelevant information.

vbuberen avatar Sep 29 '23 12:09 vbuberen

Does not support android intent:// scheme in a way that evokes third-party apps。

You need to explain it better as currently it is hard to understand what you want, not to mention that Logs section with completely irrelevant information.

Rewrote the commented, thanks

fzdfy avatar Oct 23 '23 06:10 fzdfy

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days

github-actions[bot] avatar Jan 22 '24 00:01 github-actions[bot]

This Intent is seen when using WebView. Please see here for more details.

Usually need like below code.

        if (url.startsWith("intent://")) {
            val intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
            context.startActivity(intent)
        }

alpha2048 avatar Mar 18 '24 03:03 alpha2048

Same problem here, my existing app use

 if (url.startsWith("intent://")) {
            val intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
            context.startActivity(intent)
        }

But I have no equivalent in Flutter (as I know).

Example of intent I have is: intent://payment#Intent;action=ch.twint.action.TWINT_PAYMENT;scheme=twint;S.code=98815;S.startingOrigin=EXTERNAL_WEB_BROWSER;S.browser_fallback_url=;end

Using

final intent = AndroidIntent(
                action: 'action_view',
                data: Uri.encodeFull(request.url),
              );
              intent.launch();

Will just give the error PlatformException(ACTIVITY_NOT_FOUND, No Activity found to handle intent { intent://payment#Intent;action=ch.twint.action.TWINT_...

jaumard avatar May 30 '24 07:05 jaumard

Pull request open to support this format. Please take a look and let me know https://github.com/fluttercommunity/plus_plugins/pull/2970

jaumard avatar May 30 '24 08:05 jaumard

Thanks again @jaumard for the contribution!

Merged this, it will probably take a while until we release this, but you can use git-ref in pubspec meanwhile: https://dart.dev/tools/pub/dependencies#git-packages

miquelbeltran avatar May 31 '24 05:05 miquelbeltran