Brian L. Clark
Brian L. Clark

Reputation: 628

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

Upvotes: 8

Views: 3118

Answers (2)

wang wood
wang wood

Reputation: 1

handle extension as per below below in share extension's viewdidload: works

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

Upvotes: 0

Brian L. Clark
Brian L. Clark

Reputation: 628

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)
    }
}

Upvotes: 14

Related Questions