Sharing Extension in IOS8 beta

后端 未结 7 1947
天命终不由人
天命终不由人 2020-12-24 08:40

I\'m trying to create a sharing extension using the new iOS 8 app extensions. I tried to get the current URL of a Safari site to show it in a UILabel. Simple enough.

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-24 09:19

    You need to be looking for an attachment of type kUTTypePropertyList. Do something like this with the first attachment of the first extension item in your extension:

    NSExtensionItem *extensionItem = self.extensionContext.extensionItems.firstObject;
    NSItemProvider *itemProvider =  self.extensionItem.attachments.firstObject;
    [itemProvider loadItemForTypeIdentifier:kUTTypePropertyList options:nil
      completionHandler:^(NSDictionary *item, NSError *error) {
       // Unpack items from "item" in here
    }];
    

    You'll also need to setup some JavaScript to pick up all of the data you need from the DOM. See the second extensions session from WWDC 14 for more details.

提交回复
热议问题