[英]how do I connect to FB from WITHIN my ios app?
I have a popular medicine app often used by med students and residents at the bedside. 我有一个流行的医学应用程序,经常被医学生和床边的居民使用。 I incorporated the new FB SKD into my last updated which, when opened for the first time (and subsequently if not used for a few days), opens the native FB app then redirects to my app.
我将新的FB SKD合并到我的上次更新中,该文件在首次打开时(如果几天不使用,则在随后打开)时打开本机FB应用程序,然后重定向到我的应用程序。 Many customers have complained because the info within the app often needs to be looked up quickly (crashing patient).
许多客户抱怨说,因为应用内的信息通常需要快速查找(导致患者崩溃)。
Is it possible to set up my app so the user needs to click on a button within the app before connecting to FB? 是否可以设置我的应用程序,以便用户需要在连接到FB之前单击应用程序中的按钮? Thanks!
谢谢!
When you download the FB SDK you get a sample project. 下载FB SDK时,您将获得一个示例项目。 Compile and run it, and you should see a toggle button that allows user to login/logout.
编译并运行它,您应该看到一个允许用户登录/注销的切换按钮。 You've got the FB official images in that project, and the code behind it is pretty simple:
您已经在该项目中获得了FB官方图像,其背后的代码非常简单:
/**
* Called on a login/logout button click.
*/
- (void)fbButtonClick:(id)sender {
if (fbButton.isLoggedIn) {
[self logout];
} else {
[self login];
}
}
/**
* Show the authorization dialog.
*/
- (void)login {
[_facebook authorize:nil delegate:self];
NSLog(@"Sas");
}
/**
* Invalidate the access token and clear the cookie.
*/
- (void)logout {
[_facebook logout:self];
}
You should also change the button's state in the FBAuth delegate methods (which you've already implemented) by calling a method similar to this one: 您还应该通过调用类似于以下方法的方法在FBAuth委托方法(已实现)中更改按钮的状态:
- (void)updateFbButtonAccordingToSessionStatus {
//Check if session is valid and update button accordingly
if ([self.facebook isSessionValid] == NO ) {
fbButton.isLoggedIn = NO;
[fbButton updateImage];
}
else {
fbButton.isLoggedIn = YES;
[fbButton updateImage];
}
}
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.