GeekyAnts / external_app_launcher

BSD 3-Clause "New" or "Revised" License
14 stars 31 forks source link

Open app by link #9

Open ezze opened 2 years ago

ezze commented 2 years ago

I wonder whether it's possilbe to support opening the app using intent, e.g. I want to open Telegram channel by tg:// link like it's shown here. Probably, this PR may be related.

At the moment a have the following code snippet relying on url_launcher as a workaround:

Future<void> launchApp({
  required String androidPackageName,
  required String iosUrlScheme,
  required String appStoreLink,
  required String? link,
}) async {
  if (link == null || !await LaunchApp.isAppInstalled(
    androidPackageName: androidPackageName,
    iosUrlScheme: iosUrlScheme,
  )) {
    await LaunchApp.openApp(
      androidPackageName: androidPackageName,
      iosUrlScheme: iosUrlScheme,
      appStoreLink: appStoreLink,
      openStore: true,
    );
    return;
  }

  if (!await canLaunch(link)) {
    return;
  }
  await launch(link);
}
KrishanMadushanka commented 2 years ago

I used the same workaround @ezze