tufekoi
tufekoi

Reputation: 991

Cannot open url scheme correctly from flutter app

I have this scheme

"intent://reader/20667#Intent;scheme=marvelunlimited;package=com.marvel.unlimited;end" 

which can be open without any trouble from web browsers (chrome and firefox) on my android phone.

But when I try to open it from my app I get this error message :

[ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter (24461): Could not launch intent://reader/20667#Intent;scheme=marvelunlimited;package=com.marvel.unlimited;end

the problem is that the marvel API gives "inAppLink" url scheme such as this :

"inAppLink": "https://applink.marvel.com/issu/20480?utm_campaign=apiRef&utm_source=8d9925577b747f5266703258c321f5ba",

but that simply open a web page.

I use this in my code to open them :

_launchURL() async {
    var url = "intent://reader/20667#Intent;scheme=marvelunlimited;package=com.marvel.unlimited;end";
    if (await canLaunch(url)) {
      await launch(url);
    } else {
      throw 'Could not launch $url';
    }
  }

What do I need to change in any of this url/schemes to open the marvel unlimited app from my flutter app?

Upvotes: 1

Views: 3581

Answers (1)

Alécio Carvalho
Alécio Carvalho

Reputation: 13657

You can configure it using the android_intent plugin...here an example:

if (platform.isAndroid) {
    AndroidIntent intent = new AndroidIntent(
    action: 'action_view',
    data: 'https://play.google.com/store/apps/details?'
      'id=com.google.android.apps.myapp',
    arguments: {'authAccount': currentUserEmail},
    );
   await intent.launch();
}

Just translate the expected intent into this format and it should work. Specify the package: 'com.marvel.unlimited' to go directly to the app.

Good luck!

Upvotes: 1

Related Questions