When your app uses UIDocumentInteractionController or UIActivityViewController to share a single PDF file, Badger's action extensions appear in the standard iOS share sheet if they've been enabled by the user. This all happens automatically—with no modifications to your code our extensions enable users to review most of the properties exposed by PDFKit.

To support in-place modification of PDF files, you must use UIActivityViewController and provide a callback block and overwrite the original data with the edited version (with a user's consent, if appropriate).

Badger returns an NSExtensionItem with one attachment (NSItemProvider) containing the modified PDF data. Use NSItemProvider's functions to load the data or a file representation, depending on your needs:

NSURL *url; // your PDF file
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[url] applicationActivities:nil];

// this completion handler is called when our extension returns a modified document
activityViewController.completionWithItemsHandler = ^(UIActivityType _Nullable activityType, BOOL completed, NSArray * _Nullable returnedItems, NSError * _Nullable activityError) {

	if (activityError) { /* handle error as needed */ }
	else if (returnedItems.count) {

		// Badger returns one extension item; other extensions may behave differently
		NSExtensionItem *extensionItem = returnedItems.firstObject;
		NSArray *attachments = extensionItem.attachments;
		for (id object in attachments) {
			// we deliver the results as an NSItemProvider that includes a single, PDF representation
			if ([object isKindOfClass:[NSItemProvider class]]) {
				NSItemProvider *provider = (NSItemProvider *)object;
				NSString *typeString = (__bridge NSString *)kUTTypePDF;
				if ([provider hasItemConformingToTypeIdentifier:typeString]) {
					[provider loadFileRepresentationForTypeIdentifier:typeString completionHandler:^(NSURL * _Nullable url, NSError * _Nullable error) {
						// handle error or use the file

// present the activity view controller as appropriate