美文网首页
Facebook第三方登陆

Facebook第三方登陆

作者: barrylyl | 来源:发表于2015-08-25 00:26 被阅读804次

    登陆Facebook开发者平台: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

    //设置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.现在你的app就可以使用facebook第三方登陆

    相关文章

      网友评论

          本文标题:Facebook第三方登陆

          本文链接:https://www.haomeiwen.com/subject/eehgqttx.html