PM-1731 - Changed UIDocumentInteractionController with UIDocumentPickerViewController (#2472)

This commit is contained in:
aj-rosado 2023-04-13 19:51:56 +01:00 committed by GitHub
parent ac3b0c2bad
commit 0c4b88e562
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,7 +5,6 @@ using System.Threading.Tasks;
using Bit.App.Resources;
using Bit.Core.Abstractions;
using Bit.iOS.Core.Utilities;
using CoreGraphics;
using Foundation;
using MobileCoreServices;
using Photos;
@ -29,11 +28,20 @@ namespace Bit.iOS.Core.Services
var filePath = Path.Combine(GetTempPath(), fileName);
File.WriteAllBytes(filePath, fileData);
var url = NSUrl.FromFilename(filePath);
var viewer = UIDocumentInteractionController.FromUrl(url);
var controller = UIViewControllerExtensions.GetVisibleViewController();
var rect = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ?
new CGRect(100, 5, 320, 320) : controller.View.Frame;
return viewer.PresentOpenInMenu(rect, controller.View, true);
try
{
UIView presentingView = UIApplication.SharedApplication.KeyWindow.RootViewController.View;
var documentController = new UIDocumentPickerViewController(url, UIDocumentPickerMode.ExportToService);
controller.PresentViewController(documentController, true, null);
return true;
}
catch
{
return false;
}
}
public bool CanOpenFile(string fileName)