if let hostAppId = Bundle.main.object(forInfoDictionaryKey: HOST_APP_IDENTIFIER_INFO_PLIST_KEY) as? String {
self.hostAppId = hostAppId
@@ -33,6 +33,13 @@ class ShareViewController: SLComposeServiceViewController {
} else {
print("Error: \(NO_INFO_PLIST_URL_SCHEME_ERROR)")
}
+
+ guard let items = extensionContext?.inputItems as? [NSExtensionItem] else {
+ cancelRequest()
+ return
+ }
+
+ handlePost(items)
}
override func isContentValid() -> Bool {
@@ -40,16 +47,6 @@ class ShareViewController: SLComposeServiceViewController {
return true
}
- override func didSelectPost() {
- // This is called after the user selects Post. Do the upload of contentText and/or NSExtensionContext attachments.
- guard let items = extensionContext?.inputItems as? [NSExtensionItem] else {
- cancelRequest()
- return
- }
-
- handlePost(items)
- }
-
override func configurationItems() -> [Any]! {
// To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here.
return []
@@ -238,11 +235,10 @@ class ShareViewController: SLComposeServiceViewController {
func completeRequest() {
// Inform the host that we're done, so it un-blocks its UI. Note: Alternatively you could call super's -didSelectPost, which will similarly complete the extension context.