Unable to open an `itms-service` URL using `url_launcher` with a AWS link

402 views Asked by At

Hope someone has gone thru the same issue and can help me here: I’m trying open a URL with the scheme itms-service using a AWS link with manifest.plist link using url_launcher library but I’m getting an error:

This is only on iOS app and the point of it is to be able to force update the app if it is on a lower version, this is currently only under an Enterprise certificate and not in the AppStore

Steps to Reproduce

 final uri = Uri(path: 'itms-services://?action=download-manifest&url=https://awsservice.com/build/manifest.plist');
    if (await canLaunchUrl(uri)) {
      await launchUrl(uri);
    } else {
      throw 'Could not launch $url';
    }

Actual results (Errors):

\-canOpenURL: failed for URL: "itms-services://?action=download-manifest&url=https://awsservice.com/build/manifest.plist" - error: "Invalid input URL"

Failed to open URL itms-services%3A//%3Faction=download-manifest&url=https://awsservice.com/build/manifest.plist: Error Domain=NSOSStatusErrorDomain Code=-50 "invalid input parameters" UserInfo={NSDebugDescription=invalid input parameters, \_LSLine=249, \_LSFunction=-\[\_LSDOpenClient openURL:fileHandle:options:completionHandler:\]}

  • I’ve tried encoding the url string but nothing seems to work: Uri(path: Uri.encodeFull(url));
  • I've also tried adding itms-service as a UrlScheme. (but honestly this should be a default scheme for iOS)

Expected results:

Being able to open the link and download the app

1

There are 1 answers

0
Keylin Wu On

The answer was actually in the parsing of the stringL

Using Uri.parse is what solves it:

  final uri = Uri.parse(url);
    if (!await launchUrl(uri)) {
      throw 'Could not launch $url';
    }