gpt4 book ai didi

swift - Facebook 共享对话框失败 - 操作无法快速完成

转载 作者:行者123 更新时间:2023-11-28 05:50:09 25 4
gpt4 key购买 nike

我正在 iphone 设备上测试,用户已登录 facebook 应用程序。

do, catch block 中我得到错误 error is message: The operation couldn't be completed. (FacebookShare.ShareError 错误 0。)在/Users/bogdanbarbulescu/Desktop/myStreet.com/myStreet.com/MessagesViewController.swift 中的第 895 行。

我在 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 trace

2018-11-11 09:38:12.238951+0000 myStreet.com[6129:1364819] [core] SLComposeViewController isAvailableForServiceType com.apple.social.facebook 2018-11-11 09:38:12.257468+0000 myStreet.com[6129:1364819] [core] SLComposeViewController isAvailableForServiceType got serviceType com.apple.social.facebook isAvailable 0 2018-11-11 09:38:12.295729+0000 myStreet.com[6129:1365297] [core] SLComposeViewController _shareExtensionWithIdentifier: continuous discovery block got extensions ( " {id = com.apple.share.SinaWeibo.post}", " {id = com.apple.share.TencentWeibo.post}", " {id = com.apple.share.Facebook.post}", " {id = com.apple.share.Vimeo.post}", " {id = com.apple.Music.MediaSocialShareService}", " {id = com.apple.mobileslideshow.StreamShareService}", " {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}" ) error (null) 2018-11-11 09:38:12.296845+0000 myStreet.com[6129:1365297] [core] SLComposeViewController _shareExtensionWithIdentifier: continuous discovery block did update _identifierToShareExtensionMap { "com.apple.Health.HealthShareExtension" = " {id = com.apple.Health.HealthShareExtension}"; "com.apple.Music.MediaSocialShareService" = " {id = com.apple.Music.MediaSocialShareService}"; "com.apple.mobilenotes.SharingExtension" = " {id = com.apple.mobilenotes.SharingExtension}"; "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.com[6129:1364819] [core] SLComposeViewController isAvailableForServiceType returning YES for overridden extensionIdentifier com.apple.share.Facebook.post 2018-11-11 09:38:12.298988+0000 myStreet.com[6129:1364819] [core] SLComposeViewController isAvailableForServiceType com.apple.social.facebook returning 1 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.

最佳答案

你错过了图书馆

import FBSDKShareKit

让这段代码工作

let content = FBSDKShareLinkContent()
content.contentURL = URL(string: "https://developers.facebook.com")
FBSDKShareDialog.show(from: self, with: content, delegate: self)

关于swift - Facebook 共享对话框失败 - 操作无法快速完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53247543/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com