I have a web app which, on user request, queries a backend api for a pdf and then displays it in a separate browser tab. The code for this works (code path when isFlutterApp=false) and looks like this:
let pdf = await Api.getReceiptAsPdf(receipt.id);
var file = new Blob([pdf], {type: 'application/pdf'});
var fileURL = URL.createObjectURL(file);
//fileURL looks like: blob:https://my.example.com/2e48a922-513d-4cb4-8e1f-148d6b7d2640
if (isFlutterApp) sendFlutterNotification(fileURL);
else window.open(fileURL);
The web app may also run in a Flutter App (in a flutter web view) and then the code above sends the fileURL to the Flutter App instead of calling window.open. In that case I use url_launcher and open the same fileUrl via Flutter:
//fileURL is (e.g.) blob:https://my.example.com/2e48a922-513d-4cb4-8e1f-148d6b7d2640
void _launchURL(u) async =>
await canLaunch(u) ? await launch(u) : throw 'Could not launch $u';
This does not work, I get:
-canOpenURL: failed for URL: "blob:https://my.example.com/2e48a922-513d-4cb4-8e1f-148d6b7d2640" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
[VERBOSE-2:ui_dart_state.cc(186)] Unhandled Exception: Could not launch blob:https://my.example.com/2e48a922-513d-4cb4-8e1f-148d6b7d2640
#0 _MyState._launchURL (package:flutterwrapper/main.dart:173:46)
I have only tested this on ios so far, and have added in info.plist the following entry:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>blob</string>
</array>
What could be the problem here?