Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excluding own application from UiActivityViewController

I am trying to remove my own applications share extension from showing up in the share options. I can't find any documentation on this online. Any help would be appreciated.

This is what I have so far:

activityVC.excludedActivityTypes = [UIActivityTypeAirDrop, UIActivityTypeAddToReadingList,"com.Final.Giftr.Giftr-ShareExtension"]

The Air drop and add to reading list are working as expected.

like image 924
onemillion Avatar asked Apr 01 '16 10:04

onemillion


People also ask

What is uiactivityviewcontroller on iOS?

On iOS, UIActivityViewController provides a unified interface for users to share and perform actions on strings, images, URLs, and other items within an app. You create a UIActivityViewController by passing in the items you want to share and any custom activities you want to support (we’ll show how to do that later on).

How do I exclude certain activity types in uiactivityviewcontroller?

By default, UIActivityViewController shows all the activities available for the items provided, but you can exclude certain activity types via the excludedActivityTypes property. Activity types are divided up into “action” and “share” types:

How do I show custom share and action extensions in uiactivityviewcontroller?

As a user, you just click the more button to show the ones you want in the share sheet. As a developer, you don’t have to do anything to your UIActivityViewController to show custom Share and Action Extensions. Apple made sharing from your apps incredibly easy with the addition of UIActivityViewController.

How do I restore the state of a child UIViewController?

With DecodeRestorableState (NSCoder), allows custom state restoration. With BeginAppearanceTransition (Boolean, Boolean), tells child UIViewController s that their child views have just appeared or disappeared. The array of child UIViewController objects that should be searched to determine if they are the unwind segue destination.


1 Answers

You want to look into NSExtensionActivationRule, in your share extension's Info.plist. At a high level, you want to additionally share an item with a custom UTI, and make your share extension exclude that UTI.

Check out this blog post from the PSPDFKit team.

However, as a caveat, PSPDFKit have stopped using this approach, since some third party extensions will only activate if they can share every item that is being presented… in the case of this approach, it would mean that some third party extensions would not show up. See the update at the bottom of the blog post.

like image 196
Amy Worrall Avatar answered Nov 09 '22 23:11

Amy Worrall