Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Share extension how to support *.wav files

As the title states, I want my extension to show up when the users share *.wav files

I've come across the following apple documentation: https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#//apple_ref/doc/uid/TP40014214-CH21-SW8

I'm trying to figure out how to actually use what is mentioned in the documentation to do so. The documentation leaves me with the feeling I have most if not all the pieces I need, but not how they go together.

I understand that I'll most probably have to build a "SUBQUERY(..)" statement, but where does it go? How do I use it?

like image 207
LostBalloon Avatar asked Apr 09 '15 18:04

LostBalloon


1 Answers

I ended up doing the following:

for the NSExtensionActivationRule key, I changed the type from Dictionary to String and entered the following string (you can keep the formatting, doesn't need to be all inline):

SUBQUERY (
    extensionItems,
    $extensionItem,
    SUBQUERY (
        $extensionItem.attachments,
        $attachment,
        ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image" ||
        ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.movie" ||
        ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.audio"
    ).@count == $extensionItem.attachments.@count
).@count >= 1

You only need the:

ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.audio"

but my extension also supports movies and images which is why it has those too (left it in for those that may be curious how to support more than one. Note that I've decided to support more audio options than just waves as I was initially inquiring about. The types can be looked up here: Uniform Type Identifiers Reference

The first count check makes sure that every single selected item in the host app conforms with the extension.

The second count check, the one at the end is used to indicate that the extension accepts 1 or more items (that conform). If you wanted to only allow for 1 item at the time to be processed by your extension you would enter the following:

).@count == 1

or, if you wanted to allow for multiple items with an upper limit:

).@count < 4

or

).@count <= 3
like image 197
LostBalloon Avatar answered Sep 18 '22 01:09

LostBalloon