NSExtensionActivationRule & iOS app extension: how to activate an extension in iTunes

I want to make an extension for my iOS 8 application (preferably an action extension, but the sharing extension will also do the job).
And I want this extension to be available from iTunes so that my users can send the iTunes link to my application.
But I just canโ€™t figure out how to make this extension available from iTunes (and only from iTunes by the way).
I tried NSExtensionActivationRule.NSExtensionActivationSupportsWebURLWithMaxCount, but it only activated my extension from Safari and not from iTunes.
I wonder if there could be a way to do this with a predicate, but I can't figure out how to build a predicate that can detect an iTunes item / link (due to the lack of a better term).
Does anyone have a solution for this?

+5
source share
1 answer

The NSExtensionItem from the AppStore / iTunes Store apps actually contains three types of attachments, which are image, text, and URL.

You can specify NSExtensionActivationRule in TRUEPREDICATE first in development, which allows you to use all kinds of attachments.

AppStore / iTunes Store application extension request attachment structure can be registered as an image: enter image description here

As a result, you should include the following keys in the NSExtensionActivationRule of your info.plist extension file:

  • NSExtensionActivationSupportsImageWithMaxCount
  • NSExtensionActivationSupportsText
  • NSExtensionActivationSupportsWebURLWithMaxCount

Update:

If you want to limit a possible point showing the extension (which only works in the iTunes Store), you can use the "predicate" for a more complex filter.

Refer to the Apple document below: https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/ExtensionScenarios.html#//apple_ref/doc/uid/TP40014214-CH21-SW8

For instance:

I want my extension to be displayed only if the extensionโ€™s attachments meet the condition: one image, one plain text and one URL, which confirms the state as the image above. I use the following prediction:

SUBQUERY ( extensionItems, $extensionItem, SUBQUERY ( $extensionItem.attachments, $attachment, ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image" ) .@count == 1 ) .@count == 1 && SUBQUERY ( extensionItems, $extensionItem, SUBQUERY ( $extensionItem.attachments, $attachment, ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.url" ) .@count == 1 ) .@count == 1 && SUBQUERY ( extensionItems, $extensionItem, SUBQUERY ( $extensionItem.attachments, $attachment, ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.plain-text" ) .@count == 1 ) .@count == 1 

I did not try to filter inside the attachment (only the url contains "itunes.apple.com"), but I think you can use the prediction to limit the point extension displayed in the action sheet and do a lot of checking before taking action inside your view controller (not an ideal solution, but should work if there is no better way to check the contents of attachments).

Hurrah!

+13
source

Source: https://habr.com/ru/post/1201852/


All Articles