ios – FBDialogs presentShareDialogWithParams回调处理程序永远不会被调用

我正在使用FBDialogs在Facebook上分享.

Facebook共享工作正常,但处理程序永远不会被调用(我在第一行放置断点)

我的SDK是通过CocoaPods安装的

pod 'Facebook-iOS-SDK','3.9.0'

这是代码,几乎是facebook dev页面上的示例.我正在使用ios7测试iPod.

// If the Facebook app is installed and we can present the share dialog
if ([FBDialogs canPresentShareDialogWithParams:params]) {
    // Present the share dialog

    [FBDialogs presentShareDialogWithParams:params
                              clientState:nil
                                    handler:^(FBAppCall *call,NSDictionary *results,NSError *error) {
                                        //never gets here
                                        if(error) {
                                            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
                                                                                            message:[Nsstring stringWithFormat: @"O comparilhando não foi bem sucedido. %@",error.description]
                                                                                           delegate:nil
                                                                                  cancelButtonTitle:@"OK"
                                                                                  otherButtonTitles:nil];
                                            [alert show];

                                        } else {
                                            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Sucesso"
                                                                                            message:@"O compartilhando foi bem sucedido"
                                                                                           delegate:nil
                                                                                  cancelButtonTitle:@"OK"
                                                                                  otherButtonTitles:nil];
                                            [alert show];

                                        }}];

解:

我的老板最终弄明白了.
我在AppDelegate中错过了这个方法.没有它,Facebook无法将数据传回我的应用程序

-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:        (Nsstring *)sourceApplication annotation:(id)annotation {

BOOL urlWasHandled = [FBAppCall handleOpenURL:url
                            sourceApplication:sourceApplication
                              fallbackHandler:^(FBAppCall *call) {
                                  // incoming link processing goes here
                                }];

    return urlWasHandled;
}

解决方法

- (BOOL)application:(UIApplication *)application
            openURL:(NSURL *)url
  sourceApplication:(Nsstring *)sourceApplication
         annotation:(id)annotation {


    if ([[[[Nsstring stringWithFormat:@"%@",url] componentsSeparatedByString:@":"] objectAtIndex:0]isEqualToString:@"your FB ID"]) {

        return [FBSession.activeSession handleOpenURL:url];

    }

可能对你有所帮助.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...