Swift将Youtube链接发送到URL

时间:2018-04-07 14:39:30

标签: ios swift

我的朋友创建了一个播放一些音乐视频等的网络应用程序。我创建了一个iOS应用程序,显示该网络应用程序的webview。

我们希望当人们在Youtube上按下分享时,我们的应用会将此Youtube链接发送到特定网址,以便网络应用可以将此视频添加到他们的播放列表中。

我尝试了一点扩展分享,但我认为我做错了。

if let item = extensionContext?.inputItems.first as? NSExtensionItem {
    if let itemProvider = item.attachments?.first as? NSItemProvider {
        if itemProvider.hasItemConformingToTypeIdentifier("public.url") {
            itemProvider.loadItem(forTypeIdentifier: "public.url", options: nil, completionHandler: { (url, error) -> Void in
                if let shareURL = url as? NSURL {
                    print("thats the ",shareURL)

                }
                self.extensionContext?.completeRequest(returningItems: [], completionHandler:nil)
            })
        }
    }
}

0 个答案:

没有答案