Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you create a Share Extension in iOS8 without a share UI

I was using Pocket and they seem to have created a share extension that simply posts the URL to their service w/o a UI.

Anyone have an idea on how to replicate this? I'm new to extensions but very familiar with iOS/Objective-C

enter image description here

enter image description here

like image 454
Brian L. Clark Avatar asked Feb 22 '15 17:02

Brian L. Clark


People also ask

What is a share extension?

The main feature of share extensions is to make your content preview correctly on Workplace. This entails providing support for authenticated preview metadata in a format Workplace expects, such that when URLs to your content are shared, Workplace can fetch that metadata and create a preview.

What is the share sheet extension on my Iphone?

Overview. Using the iOS share sheet, users can launch your messaging app instantly from a list of suggestions when sharing content like a link, image, video, or file.

What is the iOS app extension?

App Extensions are an iOS feature that allows developers to extend the functionality and content of their app beyond the app itself, making it available to users in other apps or in the main operating system.


1 Answers

Figured it out.

Just don't use the built in SLComposeServiceViewController

@interface ShareViewController : UIViewController

@end

And make sure to call the following function when done with the share extension

[self.extensionContext completeRequestReturningItems:@[] completionHandler:nil];

In other words, replace the contents of ShareViewController.swift with:

import UIKit

class ShareViewController: UIViewController {
    override func viewDidLoad() {
        extensionContext?.completeRequest(returningItems: [], completionHandler: nil)
    }
}
like image 134
Brian L. Clark Avatar answered Sep 22 '22 11:09

Brian L. Clark