I am testing v1.2.0-Pre the new Launcher.OpenAsync included with this: https://github.com/xamarin/Essentials/pull/773
The Share and the Open work wonderful with Android. On iOS I seem to be struggling with the Open. Share works fine on iOS.
await Launcher.OpenAsync(new OpenFileRequest(this.fileCaption, new ReadOnlyFile(fn)));The native app selection dialog opens up like it does on Android. Selecting this opens the file in the selected app.
Nothing at all happens.
This only affects iOS. I have tried on a physical 12.3 iPad and a 12.2 emulator.
Xamarin.Essentials v1.2.0-Pre
Please note: when I call this:
var uri = new Uri(fn);
var supportsUri = await Launcher.CanOpenAsync(uri.Scheme + @"://");
the uri.Scheme = "file" and the Launcher.CanOpenAsync returns false.
string fn = this.FileName_FullIncludingPath;
var uri = new Uri(fn);
var supportsUri = await Launcher.CanOpenAsync(uri.Scheme + @"://");
if (supportsUri)
await Launcher.OpenAsync(new OpenFileRequest(this.fileCaption, new ReadOnlyFile(fn)));
CanOpenAsync is only for non-files... so no need to check that. Try it without that.
Yep, sorry if it was ambiguous. I was using just:
await Launcher.OpenAsync(new OpenFileRequest(this.fileCaption, new ReadOnlyFile(fn)));
but I had also tried the "CanOpenAsync" and added that info in as I thought it might be the cause.
Launcher.OpenAsync() just does nothing. No exception or diagnostic message that I can see.
Hi again, I decided to download the Xamarin.Essentials code and link it up to see what is going on. Unfortunately I don't have anything interesting to report
In the "PlatformOpenAsync" function:
After reading: https://developer.apple.com/documentation/uikit/uidocumentinteractioncontroller/1616807-presentopeninmenu
Return value: true if this method was able to display the menu or false if it was not.
but the PresentOpenInMenu() is actually returning true.
Below is the vc.View being used:
{<UIView: 0x105fb4d00; frame = (0 0; 768 1024); autoresize = W+H; layer = <CALayer: 0x282b65660>>}
base: {UIKit.UIResponder}
AccessibilityHint: (null)
AccessibilityIdentifier: (null)
AccessibilityLabel: (null)
Alpha: 1
BackgroundColor: {UIKit.UIColor}
BottomAnchor: {UIKit.NSLayoutYAxisAnchor}
Bounds: {CoreGraphics.CGRect}
CanBecomeFocused: false
Center: {CoreGraphics.CGPoint}
ClassHandle: 0x262e1a408
ContentScaleFactor: 1
CoordinateSpace: {UIKit.UIView}
Focused: false
Frame: {CoreGraphics.CGRect}
GestureRecognizers: (null)
HeightAnchor: {UIKit.NSLayoutDimension}
Hidden: false
IntrinsicContentSize: {CoreGraphics.CGSize}
IsAccessibilityElement: false
Layer: {CoreAnimation.CALayer}
LeadingAnchor: {UIKit.NSLayoutXAxisAnchor}
PreferredFocusedView: {UIKit.UIView}
SafeAreaInsets: {UIKit.UIEdgeInsets}
Subviews: {UIKit.UIView[1]}
Superview: {UIKit.UIWindow}
Tag: 0
TintColor: {UIKit.UIColor}
TopAnchor: {UIKit.NSLayoutYAxisAnchor}
TrailingAnchor: {UIKit.NSLayoutXAxisAnchor}
Transform: {CoreGraphics.CGAffineTransform}
UserInteractionEnabled: true
WidthAnchor: {UIKit.NSLayoutDimension}
Window: {UIKit.UIWindow}
Ah... interesting... so this is just on an iPad and iPad simulator? Perhaps it is showing off the screen....hmmmm
How about on a phone?
Good call.
I did a test on an iPhone Xs Max 12.2 simulator:

Fixed up and will be in next release.