From 0c4b88e562158e902dcf2d1d80cff1322bff805c Mon Sep 17 00:00:00 2001 From: aj-rosado <109146700+aj-rosado@users.noreply.github.com> Date: Thu, 13 Apr 2023 19:51:56 +0100 Subject: [PATCH] PM-1731 - Changed UIDocumentInteractionController with UIDocumentPickerViewController (#2472) --- src/iOS.Core/Services/FileService.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/iOS.Core/Services/FileService.cs b/src/iOS.Core/Services/FileService.cs index bac060824..642794481 100644 --- a/src/iOS.Core/Services/FileService.cs +++ b/src/iOS.Core/Services/FileService.cs @@ -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)