iOS中Facebook登录相关知识碎片整理(三方登录SDK为友盟)

添加库

Accounts.framework 
Social.framework

AppDelegate

#import "UMSocialFacebookHandler.h"

[UMSocialFacebookHandler setFacebookAppID:@"311947182479786" shareFacebookWithURL:@"www.greatchef.com"];

点击事件

#import "UMSocial.h"
#import "UMSocialFacebookHandler.h"

UMSocialSnsPlatform *snsPlatform = [UMSocialSnsPlatformManager getSocialPlatformWithName:UMShareToFacebook];
    
    
    snsPlatform.loginClickHandler(self,[UMSocialControllerService defaultControllerService],YES,^(UMSocialResponseEntity *response){
        
        //          获取Facebook用户名、uid、token等
        
        if (response.responseCode == UMSResponseCodeSuccess) {
            
            NSDictionary *dict = [UMSocialAccountManager socialAccountDictionary];
            UMSocialAccountEntity *snsAccount = [[UMSocialAccountManager socialAccountDictionary] valueForKey:snsPlatform.platformName];
            NSLog(@"\nusername = %@,\n usid = %@,\n token = %@ iconUrl = %@,\n unionId = %@,\n thirdPlatformUserProfile = %@,\n thirdPlatformResponse = %@ \n, message = %@",snsAccount.userName,snsAccount.usid,snsAccount.accessToken,snsAccount.iconURL, snsAccount.unionId, response.thirdPlatformUserProfile, response.thirdPlatformResponse, response.message);
            
        }});

相关配置

// url scheme添加
fb311947182479786

// info.plist中添加
FacebookAppID
    311947182479786   // App ID
    FacebookDisplayName      // AppDisplayName(这些都在Facebook开发者平台获取)
    不错的App

LSApplicationQueriesSchemes  // 该键对应一个Array,如果已存在内容,请不要覆盖,合并即可
 
  fbapi
  fb-messenger-api
  fbauth2
  fbshareextension
 

相关教程

  1. [iOS常见问题] 关于facebook审核流程
  2. 链接,facebook、twitter申请id
  3. 权限参考文件 — Facebook 登录
  4. Facebook第三方登录

总结

  1. 综上所述,参考相关教程中3、4,可得知Facebook登录不需要审核,但需把app信息和联系邮箱填写完整,且iOS9无法吊起客户端
  2. Facebook分享需要审核,且需要将包含了Facebook分享功能的测试包交给Facebook进行审核测试

问题总结

Q:点击facebook三方登录时吊起的网页始终显示已经认证,无法切换帐号
A:清空safari cookie后解决

你可能感兴趣的:(iOS中Facebook登录相关知识碎片整理(三方登录SDK为友盟))