我试图让用户将最新的视频从他们的照片库分享到Facebook。我已查看http://wiki.akosma.com/IPhone_URL_Schemes#Facebook以查看网址方案,但我无法确定在我的应用中创建的正确网址。我已经成功地为Instagram做了这个,这就是它的样子:
let fetchOptions = PHFetchOptions()
fetchOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)]
let fetchResult = PHAsset.fetchAssetsWithMediaType(.Video, options: fetchOptions)
if let lastAsset = fetchResult.firstObject as? PHAsset {
let localIdentifier = lastAsset.localIdentifier
let u = "instagram://library?LocalIdentifier=" + localIdentifier
let url = NSURL(string: u)!
if UIApplication.sharedApplication().canOpenURL(url) {
UIApplication.sharedApplication().openURL(NSURL(string: u)!)
}
}
成功完成此任务的正确方法是什么?