我正在测试一个on iphone设备,用户登录到facebook应用程序。
在do, catch块中,我得到了错误error is message: The operation couldn’t be completed. (FacebookShare.ShareError error 0.) on line 895 in /Users/bogdanbarbulescu/Desktop/myStreet.com/myStreet.com/MessagesViewController.swift.
我在github上发现了另一个建议:
let content = FBSDKShareLinkContent()
content.contentURL = URL(string: "https://developers.facebook.com")
FBSDKShareDialog.show(from: self, with: content, delegate: self) 但是,我得到了错误的Use of unresolved identifier 'FBSDKShareLinkContent'。如果单击FBSDKShareLinkContent()并跳转到定义,我就会得到FBSDKSharingContent.h。
我在这里做错什么了?
import UIKit
import FacebookShare
import FacebookCore
import FacebookLogin
class MessagesVC {
func invitePeopleTapped() {
let alertController = UIAlertController(title: "Some title", message: "", preferredStyle: .actionSheet)
let shareOnFacebook = UIAlertAction(title: "Share on Facebook", style: .default) { _ in
let linkContent = LinkShareContent(url: URL(string: "https://www.google.com")!, quote: "Discover & Talk ")
let shareDialog = ShareDialog(content: linkContent)
shareDialog.mode = .native
shareDialog.failsOnInvalidData = true
shareDialog.completion = { result in
print("the result is \(result)")
}
do {
try shareDialog.show()
} catch {
printsNow(message: error.localizedDescription)
}
}
alertController.addAction(shareOnFacebook)
self.present(alertController, animated: true, completion: nil)
} //end invitePeopleTapped
} //end class
Using Bolts (1.9.0)
Using FBSDKCoreKit (4.38.0)
Using FBSDKLoginKit (4.38.0)
Using FBSDKMessengerShareKit (1.3.2)
Using FBSDKShareKit (4.38.0)
Using FacebookCore (0.5.0)
Using FacebookLogin (0.5.0)
Using FacebookShare (0.5.0)
Using Firebase (5.11.0)
Using GTMSessionFetcher (1.2.0)
Using GeoFire (3.0.0)
Using GoogleAppMeasurement (5.3.0)
Using GoogleUtilities (5.3.4)
Using Protobuf (3.6.1)
Using leveldb-library (1.20)
Using nanopb (0.3.901)
Using pop (1.0.10)
Full trace trace2018-11-11 09:38:12.238951+0000 myStreet.com6129:1364819 SLComposeViewController isAvailableForServiceType com.apple.social.facebook 2018-11 09:38:12.257468+0000 myStreet.com6129:1364819 SLComposeViewController isAvailableForServiceType got com.apple.social.facebook isAvailable 0 2018-11 09:38:12.295729+0000 myStreet.com6129:1365297 SLComposeViewController _shareExtensionWithIdentifier:连续发现块got扩展( {id =com.apple.share.SinaWeibo.post},“{id = com.apple.share.TencentWeibo.post}”),“{id = com.apple.mobileslideshow.StreamShareService}",}”、“{id = com.apple.share.Vimeo.post}”、“{id = com.apple.Music.MediaSocialShareService}”、“{id =com.apple.share.Facebook.post”、“{id = com.apple.Health.HealthShareExtension}”、“{id = com.apple.reminders.RemindersEditorExtension}",”“{id = com.apple.share.Flickr.post}”、“{id = com.apple.mobilenotes.SharingExtension}”、“{id = com.apple.share.Twitter.post}”“{id = net.whatsapp.WhatsApp.ShareExtension}”)错误(null) 2018-11 09:38:12.296845+0000 myStreet.com6129:1365297 SLComposeViewController _shareExtensionWithIdentifier:连续发现块确实更新了_identifierToShareExtensionMap { "com.apple.Health.HealthShareExtension“=”{id = com.apple.Health.HealthShareExtension}";“"com.apple.mobileslideshow.StreamShareService”“=”{id = com.apple.mobileslideshow.StreamShareService}";"com.apple.reminders.RemindersEditorExtension“=”{id = com.apple.reminders.RemindersEditorExtension}";]"com.apple.share.Facebook.post“= {id =com.apple.share.Facebook.post};"com.apple.share.Flickr.post”=“{id = com.apple.share.Flickr.post}";"com.apple.share.SinaWeibo.post“=”{id = com.apple.share.Facebook.post} for extensionIdentifer com.apple.share.Facebook.post 2018-11-11 09:38:12.298926+0000 myStreet.com6129:1364819 SLComposeViewController isAvailableForServiceType“返回是被覆盖的extensionIdentifier com.apple.share.Facebook.post -11-11 09:38:12.298988+0000 myStreet.com6129:1364819 SLComposeViewController isAvailableForServiceType com.apple.social.facebook返回1错误的消息:操作无法完成。(FacebookShare.ShareError错误0.)在/Users/bogdanbarbulescu/Desktop/myStreet.com/myStreet.com/MessagesViewController.swift.的第895行
发布于 2018-11-11 18:24:05
你错过了图书馆
import FBSDKShareKit此代码才能正常工作
let content = FBSDKShareLinkContent()
content.contentURL = URL(string: "https://developers.facebook.com")
FBSDKShareDialog.show(from: self, with: content, delegate: self)https://stackoverflow.com/questions/53247543
复制相似问题