登陸Facebook開發(fā)者平臺:https://developers.facebook.com
進入平臺铐料,注冊登陸賬號后闷堡,選擇添加自己的NEW APP
輸入app詳細信息后昧碉,進入此頁面睬罗,點擊下載Facebook SDK for iOS
1.添加facebook sdk 到 Xcode Project
將facebook SDK文件中 FBSDKCoreKit.Framework苍姜、FBSDKLoginKit.FrameWork放入Xcode Project Framework文件夾中,最后更新Add Files to Project
2.配置info.plist
3.在quick start for iOS頁面輸入Bundle Identifier
4.在ViewController.m和AppDelegate.m 文件中添加頭文件申明
#import <FBSDKCoreKit/FBSDKCoreKit.h>//facebook配置
#import <FBSDKLoginKit/FBSDKLoginKit.h>
5.在ViewController.m中 viewDidLoad 方法中添加Button
//設(shè)置facebook登陸按鈕
FBSDKLoginButton*loginButton = [[FBSDKLoginButtonalloc]init];
loginButton.center=self.view.center;
[self.viewaddSubview:loginButton];
6.在AppDelegate.m文件中添加
- (void)applicationDidBecomeActive:(UIApplication*)application {
[FBSDKAppEventsactivateApp];
}
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
? ? ?return ?[[FBSDKApplicationDelegate sharedInstance] application:application didFinishLauchingWithOptions:launchOptions];
}
- (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation {
return[[FBSDKApplicationDelegatesharedInstance]application:applicationopenURL:urlsourceApplication:sourceApplicationannotation:annotation];
}
7.現(xiàn)在你的app就可以使用facebook第三方登陸