ios and flutter mixing, Open file error
[ERROR] failed to get service endpoint creating for for item at URL file:///var/mobile/Containers/Data/Application/1415D775-BCFC-486C-88C2-82F4A107E404/Documents/%E4%B8%AD%E4%BA%A4%E6%95%B0%E7%A7%91%E7%AE%A1%E7%90%86%E5%90%8E%E5%8F%B0ios%E9%A1%B5%E9%9D%A2%E6%8E%A5%E5%8F%A3%E6%96%87%E6%A1%A3.docx: Error Domain=NSCocoaErrorDomain Code=3328 "所请求的操作未能完成,因为该功能不受支持。" Collaboration: error loading metadata for documentURL:file:///var/mobile/Containers/Data/Application/1415D775-BCFC-486C-88C2-82F4A107E404/Documents/%E4%B8%AD%E4%BA%A4%E6%95%B0%E7%A7%91%E7%AE%A1%E7%90%86%E5%90%8E%E5%8F%B0ios%E9%A1%B5%E9%9D%A2%E6%8E%A5%E5%8F%A3%E6%96%87%E6%A1%A3.docx error:Error Domain=NSCocoaErrorDomain Code=3328 "所请求的操作未能完成,因为该功能不受支持。" Attempt to present <UIActivityViewController: 0x105298600> on <WKMainTabbarController: 0x1038d8fc0> (from <WKMainTabbarController: 0x1038d8fc0>) whose view is not in the window hierarchy. connection invalidated
The Flutter module can successfully open files when run separately
OpenFilePlugin.m
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {},
In this methon,[self openFileWithUIActivityViewController:fileURL]; fileURL has a value;
- (void)openFileWithUIActivityViewController:(NSURL )fileURL{}, Jump to this method, fileURL becomes to be a (NSURL)0x0
NSURL *fileURL = [NSURL fileURLWithPath:filePath]; There is Chinese in the file path,
error log : Invalid content type identifier com.apple.pktransaction specified in extension com.apple.Passbook.QuicklookPreviewExtension
To get the real path of the file, it is recommended to use path_provider to get it, and then determine whether the app has permission to open it
// 下载缓存并预览文件
Future
if (await file.exists()) {
// 直接打开文件预览
Log.d('文件已下载,已经存在');
// 打开文件预览
final extension = path.extension(filePath).toLowerCase();
final mimeType = types[extension] ?? 'public.data';
await OpenFile.open(filePath, type: mimeType);
return;
}
// 使用 dio 下载文件
late Dio dio = Dio();
MyDialog.showLoading();
await dio.download(
url,
filePath,
onReceiveProgress: (received, total) {
Log.d('received: $received');
Log.d('total: $total');
},
);
Log.d('Download complete!');
MyDialog.dismiss();
// 打开文件预览
final extension = path.extension(filePath).toLowerCase();
final mimeType = types[extension] ?? 'public.data';
await OpenFile.open(filePath, type: mimeType);
} catch (e) {
MyDialog.dismiss();
MyToast.showToast('文件下载失败');
// 捕获异常并打印日志
Log.d('Dio error: $e');
} finally {
Log.d('Download end!');
MyDialog.dismiss();
}
}
} } types is IOS with UTI (DocumentInteraction Auto) Successfully preview files on Android and iPhone emulators, but report the above error when iOS and Flutter are mixed on iPhone
error log : Invalid content type identifier com.apple.pktransaction specified in extension com.apple.Passbook.QuicklookPreviewExtension
I'm not experienced mixed with the situation, but I found the same problem on here, said it may be just a warning
error log : Invalid content type identifier com.apple.pktransaction specified in extension com.apple.Passbook.QuicklookPreviewExtension
I'm not experienced mixed with the situation, but I found the same problem on here, said it may be just a warning
I have already sent channelMethod using mixed encoding and processed it using iOS native, temporarily resolving this issue
error log : Invalid content type identifier com.apple.pktransaction specified in extension com.apple.Passbook.QuicklookPreviewExtension
I'm not experienced mixed with the situation, but I found the same problem on here, said it may be just a warning
Anyway, thank you very much