I have a weird issue with my iOS part of Xamarin Forms application.
I have set up my app to open VCard using this Info.Plist:
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<!-- Some application keys/values stripped for clarity -->
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>VCard Files</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSHandlerRank</key>
<string>Alternate</string>
<key>LSItemContentTypes</key>
<array>
<string>public.vcard</string>
</array>
</dict>
</array>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<!--<key>UISupportsDocumentBrowser</key>
<true/>-->
</dict>
</plist>
And it works ...
When a VCard is opened in Safari, it shows a preview of that VCard.
Using the "Share" button, I can see my application in 2 locations:
1 with an Icon (number 1 on the screenshot),
1 with only text (number 2 on the screenshot).
If I use the text button(2), my app opens normally (or goes to foreground if already running) and I'm able to deal with the VCard content, so far so good.
But, and here comes the issue, if I use the Icon button(1), my app does not open and the Share panel becomes irresponsible.
I have no log from my application (OpenUrl function is not called).
The only info about this non-crash comes from the iDevice logs (caught using idevicesyslog)
sharingd[67] <Notice>: SUIOpenInAppActivity: Performing open using application [my application package] with options {
"__PayloadOptions" = {
UIApplicationLaunchOptionsSourceApplicationKey = "com.apple.mobilesafari";
};
"__PromptUnlockDevice" = 1;
"__UnlockDevice" = 1;
}
sharingd(CoreServices)[67] <Error>: LaunchServices: open operation <NSBlockOperation: 0x13fece820> failed with error: Error Domain=NSOSStatusErrorDomain Code=-50 "invalid input parameters" UserInfo={NSDebugDescription=invalid input parameters, _LSLine=172, _LSFunction=-[_LSDOpenClient performOpenOperationWithURL:bundleIdentifier:documentIdentifier:isContentManaged:sourceAuditToken:userInfo:options:delegate:completionHandler:]}
sharingd[67] <Notice>: -[SUIOpenInAppActivity openResourceOperation:didFailWithError:] Error Domain=NSOSStatusErrorDomain Code=-50 "invalid input parameters" UserInfo={NSDebugDescription=invalid input parameters, _LSLine=172, _LSFunction=-[_LSDOpenClient performOpenOperationWithURL:bundleIdentifier:documentIdentifier:isContentManaged:sourceAuditToken:userInfo:options:delegate:completionHandler:]}
Just in case, here is the relevant AppDelegate.cs part:
public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
{
var decodedOptions = new UIApplicationOpenUrlOptions(options);
SLogger.LogDebug($"options == {SSilencer.Serialize(decodedOptions)}", true);
var openInPlace = decodedOptions.OpenInPlace == true;
var isScopedResource = url.StartAccessingSecurityScopedResource();
SLogger.LogDebug($"url == {url}; open in place == {openInPlace}; is scoped resource == {isScopedResource}", true);
var urlAsString = url.ToString();
if(urlAsString.StartsWith("file://") && urlAsString.EndsWith(".vcf")) {
var data = NSData.FromUrl(url, NSDataReadingOptions.Mapped, out var error);
if(error == null) {
/* This is where I'm using the data, stripped for clarity */
} else {
SLogger.LogError("unable to read content of file; path == " + urlAsString + "; error == " + error.DebugDescription);
}
}
if(isScopedResource)
url.StopAccessingSecurityScopedResource();
return true;
}
From Info.Plist, I tried to change the
"LSSupportsOpeningDocumentsInPlace" from true to false, also tried to
use "UISupportsDocumentBrowser" true instead of
"LSSupportsOpeningDocumentsInPlace", none of those made it.
What could I've missed, I'm stuck on this issue for 2 days and I have no clue nor ideas anymore.
Thanks for your assistance by advance.