使用Facebook登录时出错

时间:2014-06-02 06:46:42

标签: ios iphone objective-c facebook ipad

我制作了iPhone应用程序,其中集成了登录Facebook

当用户点击开发者设备中的使用Facebook登录按钮时,它可以正常运行。

但是,当用户在非开发者设备中点击使用Facebook登录按钮在应用商店中进行直播后,它无效(它仍可在开发者设备上使用)

在非开发者设备中它询问应用程序希望访问您的basic info用户的信息,但在此之后它没有登录,我的活动指示器会保持动画效果。

代码:

- (void)loginViewFetchedUserInfo:(FBLoginView *)
                            ok :(id<FBGraphUser>)_user {

    @try {

        [NSThread detachNewThreadSelector:@selector(threadStartAnimating) toTarget:self withObject:nil];

        NSError* error;

       // fetching user info from Fb and storing it…


        [_ActInd stopAnimating];
        [self dismissViewControllerAnimated:NO completion:nil];
    }
        @catch(NSException *exception) {
        NSLog(@"exception thrown =%@ ",exception);
    }

}

以下是我的developer.facebook.com帐户页面的屏幕截图:

: 我没有得到任何异常,方法被调用,我上面提到它在开发人员设备中运行良好(它在非开发人员设备中不起作用)

请帮助我在某个地方犯错误?或者我需要在应用程序生效后更改任何内容吗?

5 个答案:

答案 0 :(得分:3)

请检查您的项目构建设置 - &gt;包装 - &gt; Info.plist文件。 您的项目是否指向同一个info.plist?如果没有,请检查

  • 如果FacebookAppID和FacebookDisplayName与调试版相同。
  • 如果info-plist中的包标识符正确无误。

答案 1 :(得分:3)

如果您为具有绿色符号的所有用户设置了Facebook App。只需要检查设置捆绑ID 到Facebook App页面是否与您在Xcode项目捆绑标识符中使用的相同。

这里的Bellow我只是使用FBLoginView控制器的示例登录方法。我认为您不需要提交应用以供审核。

.h文件中的

使用IBOutlet创建一个按钮,并按照正常情况将此按钮连接到xib

#import <FacebookSDK/FacebookSDK.h>


@interface LoginViewController : UIViewController<FBLoginViewDelegate>
{
    IBOutlet UIButton *FB_login; // just connect IBoutlate no need to give IBAction
    FBLoginView *loginview;

}
@property (strong, nonatomic) id<FBGraphUser> loggedInUser;
@property (strong, nonatomic) IBOutlet FBProfilePictureView *profilePic; //this is for show profile pic or logged in user
<。文件

中的

@implementation LoginViewController
@synthesize profilePic = _profilePic;

- (void)viewDidLoad
{
    loginview = [[FBLoginView alloc] init];
    loginview =
    [[FBLoginView alloc] initWithPublishPermissions:[NSArray arrayWithObjects:@"publish_actions",@"email",nil] defaultAudience:FBSessionDefaultAudienceFriends];

    loginview.frame =FB_login.frame;//CGRectMake(90,149, 280, 55);
    for (id obj in loginview.subviews)
    {
        if ([obj isKindOfClass:[UIButton class]])
        {
            UIButton * loginButton =  obj;

            UIImage *loginImage = [UIImage imageNamed:@"btn_fb_login.png"];
            [loginButton setBackgroundImage:loginImage forState:UIControlStateNormal];
            [loginButton setBackgroundImage:nil forState:UIControlStateSelected];
            [loginButton setBackgroundImage:nil forState:UIControlStateHighlighted];
            [loginButton sizeToFit];
        }
        if ([obj isKindOfClass:[UILabel class]])
        {
            UILabel * loginLabel =  obj;
            loginLabel.text =@""; //@"Log in to facebook";
            loginLabel.textAlignment = NSTextAlignmentCenter;
            loginLabel.frame =CGRectMake(123,149, 280, 55);// CGRectMake(0, 0, 271, 37);
        }
    }

    loginview.delegate = self;

    [self.view addSubview:loginview];

    [super viewDidLoad];

}

-(void)LogOut:(NSNotification *)notif
{
    [self loginViewShowingLoggedOutUser:loginview];
    NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
    for (NSHTTPCookie *each in cookieStorage.cookies) {
        // put a check here to clear cookie url which starts with twitter and then delete it
        [cookieStorage deleteCookie:each];
    }
}

#pragma  mark------ FaceBook Sign In method------------

- (void)loginViewShowingLoggedInUser:(FBLoginView *)loginView {

    NSLog(@"Logged In");


}

- (void)loginViewFetchedUserInfo:(FBLoginView *)loginView
                            user:(id<FBGraphUser>)user {

    NSLog(@"%@",user);
    self.profilePic.profileID = user.id;





}
- (void)loginViewShowingLoggedOutUser:(FBLoginView *)loginView {
    // Called after logout
    NSLog(@"Logged out");

    self.profilePic.profileID = nil;
    [FBSession.activeSession closeAndClearTokenInformation];


}
- (void)loginView:(FBLoginView *)loginView handleError:(NSError *)error {
    // see https://developers.facebook.com/docs/reference/api/errors/ for general guidance on error handling for Facebook API
    // our policy here is to let the login view handle errors, but to log the results
    NSLog(@"FBLoginView encountered an error=%@", error);
}

注意: - 如果您尝试使用FBProfilePictureView设置登录用户的图像,请不要忘记将[FBProfilePictureView class];添加到应用代理中,例如Bellow

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [FBProfilePictureView class];
    // Override point for customization after application launch.
    return YES;
}

以下是您的示例代码 Sample code Facebook log-in with Image

答案 2 :(得分:1)

检查其沙盒模式,如果它没有显示绿色圆圈(如图所示),则必须将其打开。打开它后,您的应用程序将公开发布。 enter image description here

同时检查国家限制

enter image description here

答案 3 :(得分:1)

我可能有类似的情况。对于较新的应用,如果您要求的权限超过public_profile,email和user_friends,则需要提交您的应用以供审核。

Facebook方面的说法是什么:

  

评分

     

如果您的应用要求的次数超过public_profile,请发送电子邮件至   user_friends它需要在你的应用程序之前通过Facebook审查   由应用程序开发人员以外的人使用。

     

审核您的应用的时间通常为7个工作日。一些   如下所述,超敏感权限最多可能需要14个   工作日。

     

在我们的评论文档中详细了解我们的审核流程。

从这里: https://developers.facebook.com/docs/facebook-login/permissions/v2.0

答案 4 :(得分:0)

是否有待提交的提交?请检查开发人员信息中心中的“状态和审核”标签,看看您是否有任何待处理的提交。如果您有,则在获得批准之前,您无法向非测试/开发人员用户请求该权限。