pichillilorenzo / flutter_appavailability

A Flutter plugin that allows you to check if an app is installed/enabled, launch an app and get the list of installed apps.
https://pub.dartlang.org/packages/flutter_appavailability
MIT License
92 stars 89 forks source link

No implementation found for method launch app/checkAvailability #8

Open ukeOnFire opened 5 years ago

ukeOnFire commented 5 years ago

hi @pichillilorenzo I have just started to make an app iOS compatible and it seems that what has worked fine on Android is causing problems on iOS.

I tried to check the app 'calshow://', here's the exception for one of the calls:

#0      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:314:7)
<asynchronous suspension>
#1      AppAvailability.checkAvailability (package:flutter_appavailability/flutter_appavailability.dart:38:42)

Thanks for your work, it's amazingly smooth on Android!

pankti16 commented 4 years ago

Use a try-catch block:

try{
      print(await AppAvailability.checkAvailability(Platform.isIOS ? "youtube://" : "com.google.android.youtube"));
      AppAvailability.launchApp(Platform.isIOS ? "youtube://" : "com.google.android.youtube").then((_) 
      {
          print("App launched!");
      }).catchError((err) {
           Scaffold.of(context).showSnackBar(SnackBar(
               content: Text("App not found!")
           ));
          print(err);
       });
     }
     catch(ex)
     { 
        print(ex);
        Scaffold.of(context).showSnackBar(SnackBar(
                        content: Text("App not found!")
                    ));
     }