我正在使用Xcode 9和Swift 4.0。单击按钮时,我需要共享指向Facebook的链接。我已经集成了Facebook SDK。我已经完成了Facebook文档中提到的所有步骤。但我不能分享到Facebook的链接。我的代码如下。 它显示错误
-canOpenURL:网址失败:“fbauth2:/” - 错误:“操作无法完成。(OSStatus错误-10814。)”
if(FBSDKAccessToken.current() .hasGranted("publish_actions"))
{
self.postToFacebook()
}
else
{
let login: FBSDKLoginManager = FBSDKLoginManager()
login.logIn(withPublishPermissions: ["publish_actions"], from: self) { (result, error) in
if (error != nil) {
print("publish_actions: \(error!)")
} else if (result?.isCancelled)! {
print("publish_actions: Canceled")
} else if (result?.grantedPermissions.contains("publish_actions"))! {
print("publish_actions: permissions granted: \(String(describing: result?.token.tokenString))")
self.tokenString = "\(String(describing: result?.token.tokenString))"
self.postToFacebook()
//UserDefaults.standard.set(result?.token.tokenString, forKey: "facebook_token")
}
}
}
}`
func postToFacebook()
{
do{
var myContent = LinkShareContent(url: URL(string: "https://www.facebook.com/8MinuteWorkoutChallenge")!)
myContent.hashtag = Hashtag("#8MWC")
let shareDialog = ShareDialog(content: myContent)
shareDialog.mode = .native
shareDialog.failsOnInvalidData = true
shareDialog.completion = { result in
switch result {
case .success:
print("Share succeeded")
case .failed:
// self.shareButton.isHidden = true
print("failed")
case .cancelled:
print("Share cancelled")
}
}
try shareDialog.show()
}
catch {
print("Error: \(error)")
}
}
答案 0 :(得分:1)
verifyClass
(又名public interface CombinedRule extends TestRule {
default Statement apply(Statement base, Description description) {
if (description.isTest()) {
return new Statement() {
public void evaluate() throws Throwable {
before();
try {
base.evaluate();
verify();
} finally {
after();
}
}
};
}
if (description.isSuite()) {
return new Statement() {
public void evaluate() throws Throwable {
beforeClass();
try {
base.evaluate();
verifyClass();
} finally {
afterClass();
}
}
};
}
return base;
}
default void before() throws Exception {
//let the implementer decide whether this method is useful to implement
}
default void after() {
//let the implementer decide whether this method is useful to implement
}
/**
* Only runs for Tests that pass
*/
default void verify() {
//let the implementer decide whether this method is useful to implement
}
default void beforeClass() throws Exception {
before();
}
default void afterClass() {
after();
}
/**
* Only runs for Suites that pass
*/
default void verifyClass() {
verify();
}
}
)。换句话说,iOS找不到具有方案OSStatus error -10814
的应用程序......看起来您的测试设备上没有安装Facebook:)
参考:https://www.osstatus.com/search/results?platform=all&framework=all&search=10814