Currently I am only trying to do this in iOS, but I don't know where to look for how to describe an iOS file type. These are "plain text" files, but with specific odd extensions. I tried "text/plain", but that did not "light up" my files for iOS (but did allow .CSV files).
Here's the code I'm starting with...
private async void ButtonFMSPick_Clicked( object sender, EventArgs e ) {
FilePickerFileType filePickerFileType = new FilePickerFileType(
new Dictionary<DevicePlatform, IEnumerable<string>> {
{ DevicePlatform.iOS, new [] { "*.ABC", "*.123" } },
{ DevicePlatform.Android, new [] { "*.ABC", "*.123" } },
} );
PickOptions pickOptions = new PickOptions {
PickerTitle = "Select all the files",
FileTypes = filePickerFileType,
};
var results = await FilePicker.PickMultipleAsync(pickOptions);
if (results == null) {
lblFileContents.Text = "Return NULL";
return;
}
lblFileContents.Text = $" {results.Count()} files picked\r\n";
foreach (var res in results) {
try {
var stream = await res.OpenReadAsync();
lblFileContents.Text += $"File Name: {res.FileName}, len={stream.Length}, path={res.FullPath}:\r\n";
} catch (Exception ex) {
lblFileContents.Text += $"Exception: {ex}";
}
}
}
UPDATE: I took a shot at declaring the file types -- excerpt from Info.plist below, BUT I'm very unsure about this. Now I see the ".123" file type with my app icon, but still not selectable
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>ABC FILE</string>
<key>LSHandlerRank</key>
<string>Default</string>
<key>LSItemContentTypes</key>
<array>
<string>com.pronktech.abc</string>
</array>
</dict>
<dict>
<key>CFBundleTypeName</key>
<string>123 File</string>
<key>LSHandlerRank</key>
<string>Default</string>
<key>LSItemContentTypes</key>
<array>
<string>com.pronktech.123</string>
</array>
</dict>
</array>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeDescription</key>
<string>ABC FILE</string>
<key>UTTypeIdentifier</key>
<string>com.pronktech.abc</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>ABC</string>
<string>abc</string>
</array>
</dict>
</dict>
<dict>
<key>UTTypeDescription</key>
<string>123 File</string>
<key>UTTypeIdentifier</key>
<string>com.pronktech.123</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>123</string>
</array>
</dict>
</dict>
</array>
</dict>