我正在我的应用中实现签入功能。
我得到了参考网址
http://tylerwhitedesign.com/how-to-check-in-using-the-facebook-ios-sdk-and-graph-api
按照登录方式:
- (void) login {
permissions = [[NSArray arrayWithObjects: @"user_checkins", @"friends_checkins", @"publish_checkins", nil] retain];
[ facebook authorize:appID permissions:permissions delegate:self];
}
但在我的facebook sdk中: 没有支持方法“ [facebook授权:appID权限:权限委托:自我];“
帮我下载最新的Facebook SDK或提供iphone中签到功能的示例代码??
答案 0 :(得分:0)
使用FacebookSDK
对用户进行签名只需要一段代码。我并不熟悉您正在使用的特定版本。但是,离开Facebook Developer Documentation,登录用户将大致如下所示:
- (void)createAndPresentLoginView
{
if (self.loginViewController == nil) {
self.loginViewController = [[LoginViewController alloc] initWithNibName:@"LoginViewController"
bundle:nil];
self.navController = [[UINavigationController alloc] initWithRootViewController:self.loginViewController];
self.window.rootViewController = self.navController;
}
}
- (void)showLoginView
{
if (self.loginViewController == nil) {
[self createAndPresentLoginView];
} else {
[self.loginViewController loginFailed];
}
}
- (void)sessionStateChanged:(FBSession *)session
state:(FBSessionState)state
error:(NSError *)error
{
// FBSample logic
// Any time the session is closed, we want to display the login controller (the user
// cannot use the application unless they are logged in to Facebook). When the session
// is opened successfully, hide the login controller and show the main UI.
switch (state) {
case FBSessionStateOpen: {
// For gaining current location
// [self.mainViewController startLocationManager];
if (self.loginViewController != nil) {
[self initializeTabBarController];
[self.navController pushViewController:self.tabBarController animated:NO];
self.loginViewController = nil;
}
// FBSample logic
// Pre-fetch and cache the friends for the friend picker as soon as possible to improve
// responsiveness when the user tags their friends.
FBCacheDescriptor *cacheDescriptor = [FBFriendPickerViewController cacheDescriptor];
[cacheDescriptor prefetchAndCacheForSession:session];
}
break;
case FBSessionStateClosed: {
// FBSample logic
// Once the user has logged out, we want them to be looking at the root view.
UIViewController *topViewController = [self.navController topViewController];
UIViewController *modalViewController = [topViewController presentedViewController];
if (modalViewController != nil) {
[topViewController dismissViewControllerAnimated:NO completion:nil];
}
[self.navController popToRootViewControllerAnimated:NO];
[FBSession.activeSession closeAndClearTokenInformation];
[self performSelector:@selector(showLoginView)
withObject:nil
afterDelay:0.5f];
}
break;
case FBSessionStateClosedLoginFailed: {
// if the token goes invalid we want to switch right back to
// the login view, however we do it with a slight delay in order to
// account for a race between this and the login view dissappearing
// a moment before
[self performSelector:@selector(showLoginView)
withObject:nil
afterDelay:0.5f];
}
break;
default:
break;
}
[[NSNotificationCenter defaultCenter] postNotificationName:SCSessionStateChangedNotification
object:session];
if (error) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"Error: %@",
[ShindyAppDelegate FBErrorCodeDescription:error.code]]
message:error.localizedDescription
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
}
- (BOOL)openSessionWithAllowLoginUI:(BOOL)allowLoginUI
{
return [FBSession openActiveSessionWithReadPermissions:nil
allowLoginUI:allowLoginUI
completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
}
但是,您仍然需要从Facebook Developer's网站获取FacebookSDK。此外,您需要获取一个名为SCSessionStateChangedNotification
的密钥,该密钥是您的应用程序所特有的。
祝你好运!!