简体   繁体   English

在简单的IOS应用程序上使用Facebook SDK的问题

[英]Problems using Facebook SDK on simple IOS app

im trying to use facebook sdk for my IOS 5 app, i got IOS 6 working with UIActivityViewController. 我试图为我的IOS 5应用程序使用facebook sdk,我让IOS 6与UIActivityViewController一起工作。

Im using this code to show the login button 我正在使用此代码显示登录按钮

            loginview = [[FBLoginView alloc] init];

        loginview.frame = CGRectOffset(loginview.frame, 65, 50);
        [loginview setDelegate:self];   
        loginview.publishPermissions = @[@"publish_actions"];
        loginview.defaultAudience = FBSessionDefaultAudienceFriends;

        [self.view addSubview:loginview];

It shows the button properly, when i click it opens safari and ask me to give permissions to my app, i click yes, then it go back to my app but the button stay with log in text instead the log out text and any of the delegate methods (loginViewFetchedUserInfo, loginViewShowingLoggedInUser,...) gets called. 它会正确显示按钮,当我单击它会打开safari并要求我授予我的应用程序权限时,我单击是,然后返回到我的应用程序,但该按钮保留登录文本,而不是注销文本和任何委托方法(loginViewFetchedUserInfo,loginViewShowingLoggedInUser等)被调用。

My code its almost copied from the HelloFacebookSample proyect. 我的代码几乎是从HelloFacebookSample产品复制的。

I have the facebook app id and all that things in my plist file. 我的plist文件中有facebook应用ID和所有其他内容。

Im really stuck on this i cant find a solution on google so i came here to ask as my last hope. 我真的坚持这个,我无法在Google上找到解决方案,所以我来这里是我的最后希望。

Sorry for my bad english and thanks for any help. 对不起,我的英语不好,谢谢你的帮助。

change your button title in the 更改按钮标题

- (void)fbDidLogin

delegate method 委托方法

Make sure that in your app delegate you have something like this (assuming you have the 3.5 SDK) 确保在您的应用程序委托中您有类似的内容(假设您拥有3.5 SDK)

- (BOOL)application:(UIApplication *)application
        openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication
     annotation:(id)annotation {
    // attempt to extract a token from the url
    return [FBAppCall handleOpenURL:url sourceApplication:sourceApplication];
}

You need to set it up so that after Safari is shown, your app handles the URL returned and passes it on to the SDK to update the session info and in turn update the login button state. 您需要进行设置,以便在显示Safari之后,您的应用可以处理返回的URL,并将其传递给SDK以更新会话信息,然后更新登录按钮状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM