添加库
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中添加
<key>FacebookAppID</key>
<string>311947182479786</string> // App ID
<key>FacebookDisplayName</key> // AppDisplayName(这些都在Facebook开发者平台获取)
<string>不错的App</string>
<key>LSApplicationQueriesSchemes</key> // 该键对应一个Array,如果已存在内容,请不要覆盖,合并即可
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
相关教程
总结
- 综上所述,参考相关教程中3、4,可得知Facebook登录不需要审核,但需把app信息和联系邮箱填写完整,且iOS9无法吊起客户端
- Facebook分享需要审核,且需要将包含了Facebook分享功能的测试包交给Facebook进行审核测试
问题总结
Q:点击facebook三方登录时吊起的网页始终显示已经认证,无法切换帐号
A:清空safari cookie后解决
网友评论