I am not sure that you can open a file directly in another app with this method. Instead I think you need to use the UIDocumentInteractionController
to open a popup that allows the user to select the app to open the PDF in. So try this:
NSUrl adobeUrl = new NSUrl($"com.adobe.adobe-reader:");
NSUrl fileUrl = NSUrl.FromFilename(filePath);
UIDocumentInteractionController docController = UIDocumentInteractionController.FromUrl(fileUrl);
if (UIApplication.SharedApplication.CanOpenUrl(adobeUrl))
{
docController.PresentOpenInMenu(this.View.Frame, this.View, true);
}
else
{
// throw error
}
Also you need to add the Adobe Reader URL Scheme to the Info.plist. Open your Info.plist in a text editor and put the following:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>com.adobe.adobe-reader</string>
</array>
right before the last tag, e.g.
<plist version="1.0">
<dict>
...
<key>LSApplicationQueriesSchemes</key>
<array>
<string>com.adobe.adobe-reader</string>
</array>
</dict>
</plist>
Without that, you will fail the CanOpenUrl
test, so that is why nothing happened... though if you had looked in the Application output, iOS did send a message that you need to do this, e.g.:
-canOpenURL: failed for URL: "com.adobe.adobe-reader:" - error: "This app is not allowed to query for scheme com.adobe.adobe-reader"
I believe that for something like var url = new NSUrl($"com.adobe.adobe-reader://{filepath}");
to work, the file actually needs to be in Adobe Acrobat's file container already. See this SO post for more info: https://stackoverflow.com/a/21913788/2913599 [NOTE: I could not get this method to work, even with the pdf already in Adobe Acrobat's files]