launchApp method

Future<bool> launchApp()

Attempts to launch the application using the converted URL. If the application cannot be launched, it tries to open the application in the corresponding app market (Google Play for Android, App Store for iOS).

Implementation

Future<bool> launchApp() async {
  if (Platform.isAndroid) {
    try {
      return await launchUrlString((await getAppLink())!);
    } catch (e) {
      return await launchUrlString((await getMarketUrl())!);
    }
  } else if (Platform.isIOS) {
    final appLink = await getAppLink();


      if (await canLaunchUrlString(appLink!)) {
        return await launchUrlString((await getAppLink())!);
      } else {
        final marketUrl = await getMarketUrl();

        if (await canLaunchUrlString(marketUrl!)) {
          await launchUrlString(marketUrl);
        }
      }

  }
  return false;
}