ios非对话框Facebook共享失败,没有错误并且没有反馈 [英] ios non-Dialog Facebook share fails with no errors and no feedback

查看:233
本文介绍了ios非对话框Facebook共享失败,没有错误并且没有反馈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的ios应用程序中进行了一年的Facebook共享正常工作,并且已经升级(又被完全重写)以使用最新的api(4.7.x),现在共享根本无法正常工作.我检查我是否具有publish_actions权限(在调用此方法之前,我已进行此操作,在打开的图形设置,操作类型,功能中已明确共享"检查.我正在验证内容(我没有收到错误)并具有委托,它的任何方法都不会被调用.

I have had facebook sharing working fine in my ios app for a year and have upgraded (aka totally rewritten) to use the latest api (4.7.x) and now sharing doesnt work at all. I check that I have publish_actions permission (which I do prior to this method being called, I have 'expicitly shared' checked in open graph settings, action types, capabilities. I am validating the content (I dont get an error) and have a delegate, none of its methods get called.

-(void)shareWithFacebook:(NSString *)message
{
    if ([[FBSDKAccessToken currentAccessToken] hasGranted:@"publish_actions"])
    {
        NIDINFO(@"Facebook sharing has publish_actions permission");
    }
    else
    {
        FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init];
        [loginManager logInWithPublishPermissions:@[@"publish_actions"]
            handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
            {
                NIDERROR(@"Facebook sharing getting publish_actions permission failed: %@", error);
            }
        ];   
    }

    NSMutableDictionary *properties = [NSMutableDictionary dictionaryWithDictionary: @{
                                                                                   @"og:type": @"article",
                                                                                   @"og:title": @"Bloc",
                                                                                   @"og:description": message,
                                                                                   @"og:url": @"http://getonbloc.com/download"
                                                                                       }];




    FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];

        // Create the action
    FBSDKShareOpenGraphAction *action = [FBSDKShareOpenGraphAction actionWithType:@"mynamespace:Share" object:object key:@"article"];
    [action setString:@"true" forKey:@"fb:explicitly_shared"];

        // Create the content
    FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
    content.action = action;
    content.previewPropertyName = @"article";

            // Share the content
    FBSDKShareAPI *shareAPI = [[FBSDKShareAPI alloc] init];
    shareAPI.shareContent = content;
    shareAPI.delegate = self;

    NSError *error;
    if([shareAPI validateWithError:&error] == NO)
    {
        NIDERROR(@"Facebook sharing content failed: %@", error);
    }

    [shareAPI share];
}

 #pragma mark - FBSDKSharingDelegate

- (void) sharer:(id<FBSDKSharing>)sharer didCompleteWithResults:(NSDictionary *)results
{
    NIDINFO(@"Facebook sharing completed: %@", results);
}

- (void) sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error
{
    NIDERROR(@"Facebook sharing failed: %@", error);
}

- (void) sharerDidCancel:(id<FBSDKSharing>)sharer
{
    NIDINFO(@"Facebook sharing cancelled.");
}

我已经可以登录并可以正常拍照了.我完全没有从Facebook api得到任何反馈,什么也没有发布.我在这里做特别愚蠢的事情吗?

I have login working and can get photos fine. I don't get any feedback at all from the facebook api, nothing gets posted. Am I doing something particularly stupid here?

推荐答案

只是一种可能性,但是我发现Facebook集成变得不便,因为我发现每次我通过hasGranted:检查当前令牌是否具有许可权限时,即使我是在几分钟前获得许可,还是从以前的应用程序启动中获得的许可,几乎总是失败.

Just a possibility, but I find that Facebook integration has become inconvenient because I find that every time I check the current token for granted permission through hasGranted:, it almost always fail even though I gained permission a few minutes ago, or from a previous app launch.

似乎在您的代码中,如果未授予任何权限,则您尝试登录并再次获得该权限.但是,当该块返回时,无论是否授予实际许可,都将引发错误.相反,如果共享成功,则应继续进行共享.

It seems that in your code, if no permission is granted, you try to login and get the permission again. But when that block returns, regardless whether the actual permission is granted or not, you throw an error. Instead, you should continue with sharing if it is successful.

这篇关于ios非对话框Facebook共享失败,没有错误并且没有反馈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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