添加庫
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);
}});
相關(guān)配置
// url scheme添加
fb311947182479786
// info.plist中添加
<key>FacebookAppID</key>
<string>311947182479786</string> // App ID
<key>FacebookDisplayName</key> // AppDisplayName(這些都在Facebook開發(fā)者平臺獲取)
<string>不錯的App</string>
<key>LSApplicationQueriesSchemes</key> // 該鍵對應(yīng)一個Array核芽,如果已存在內(nèi)容,請不要覆蓋酵熙,合并即可
<array>
<string>fbapi</string>
<string>fb-messenger-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
</array>
相關(guān)教程
總結(jié)
- 綜上所述匾二,參考相關(guān)教程中3哮独、4,可得知Facebook登錄不需要審核察藐,但需把app信息和聯(lián)系郵箱填寫完整皮璧,且iOS9無法吊起客戶端
- Facebook分享需要審核,且需要將包含了Facebook分享功能的測試包交給Facebook進行審核測試
問題總結(jié)
Q:點擊facebook三方登錄時吊起的網(wǎng)頁始終顯示已經(jīng)認(rèn)證分飞,無法切換帳號
A:清空safari cookie后解決