I have an Action Extension
which can receive various types of files from other apps installed on the device. For this, the Info.plist
has the following entries:
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<string>
SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY (
$extensionItem.attachments,
$attachment,
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.adobe.pdf" ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.microsoft.bmp" ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.jpeg" ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.png" ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.microsoft.word.doc" ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.microsoft.excel.xls" ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.microsoft.poewerpoint.ppt" ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.file-url" ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.plain-text" ||
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url"
).@count == $extensionItem.attachments.@count
).@count == 1
</string>
<key>NSExtensionServiceToolbarIconFile</key>
<string></string>
</dict>
Here I have enlisted the UTIs of the files that my extension can accept.
Currently, my extension is visible if the user clicks Share
from a Safari webpage. But I just to want accept files and not a webpage.
So for that I removed ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url"
line. Now I don't see my extension in the browser but it also vanished from other apps like Dropbox, Google Drive.
Currently as a temporary workaround I filter the URL that contains .html
in the end and show an alert to the user saying this is not supported. But al web URLs do not have these. So is there a way, I can differentiate between an URL of a file and an URL of a webpage via Info.plist
entries or in a ViewControler
?
public.file-url
. For the full list of system-defined UTIs, see developer.apple.com/library/content/documentation/Miscellaneous/…public.file-url
but it does not detect the files stored on cloud storage apps.Content-Type
in the response header.