Facebook SDK共享总是返回sharerDidCancel [英] Facebook SDK share always returns sharerDidCancel

查看:1137
本文介绍了Facebook SDK共享总是返回sharerDidCancel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想与Facebook SDK分享讯息,但如果我分享或取消讯息,sharerDidCancel总是会呼叫。
这是我的代码

I'm trying to share a post with the Facebook SDK, but sharerDidCancel is always called, either if I share or cancel the post. Here is my code

- (void)shareFacebook {
    FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
    content.contentURL = [NSURL URLWithString:@"http://www.google.com"];
    [FBSDKShareDialog showFromViewController:view
                                 withContent:content
                                    delegate:self];
}

- (void)sharer:(id<FBSDKSharing>)sharer didCompleteWithResults :(NSDictionary*)results {
    NSLog(@"FB: SHARE RESULTS=%@\n",[results debugDescription]);
}

- (void)sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error {
    NSLog(@"FB: ERROR=%@\n",[error debugDescription]);
}

- (void)sharerDidCancel:(id<FBSDKSharing>)sharer {
    NSLog(@"FB: CANCELED SHARER=%@\n",[sharer debugDescription]);
}

这个类实现了FBSDKSharingDelegate,在我的Info.plist中我已经输入了FacebookAppID和

This class implements the FBSDKSharingDelegate, in my Info.plist I already entered the FacebookAppID and FacebookDisplayName.

在我的AppDelegate中,我有这个方法:

In my AppDelegate I have this method:

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
    return [FBAppCall handleOpenURL:url sourceApplication:sourceApplication];
}

我做错了什么?我完全按照Facebook SDK指南。

What I'm doing wrong? I exactly followed the Facebook SDK guide.

感谢

推荐答案

,我的错误是在AppDelegate方法:

Solved, my error was in the AppDelegate method:

这里是一个链接解决方案 http://jitu1990.blogspot.it/2015/05/share-with-facebook-from-ios-app.html

here is a link with the solution http://jitu1990.blogspot.it/2015/05/share-with-facebook-from-ios-app.html

这里是代码

- (BOOL)application:(UIApplication *)application openURL:(NSURL* )url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {   
    return [[FBSDKApplicationDelegate sharedInstance] application:application
                                                      openURL:url sourceApplication:sourceApplication annotation:annotation];
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    [FBSDKAppEvents activateApp];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    return [ [FBSDKApplicationDelegate sharedInstance] application :application
             didFinishLaunchingWithOptions:launchOptions]
  }

这篇关于Facebook SDK共享总是返回sharerDidCancel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆