0
我嘗試了下面的代碼,但它正在處理錯誤。如何以ios最佳方式獲取facebook accessToken?
- (void) openActiveSessionWithPermissions: (NSArray *) arr
{
if ([FBSession activeSession].state == FBSessionStateCreatedTokenLoaded){
[self openWithUI:NO permissions:arr];
} else if ([FBSession activeSession].state == FBSessionStateOpen || [FBSession activeSession].state == FBSessionStateOpenTokenExtended){
[[FBSession activeSession] closeAndClearTokenInformation];
} else {
[[FBSession activeSession] closeAndClearTokenInformation];
[self openWithUI:YES permissions:arr];
}
}
- (void) openWithUI: (BOOL) UI permissions: (NSArray *) permissions
{
[FBSession openActiveSessionWithReadPermissions:permissions allowLoginUI:UI completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
if (error) {
[self.delegate didReceieveError:[error description]];
} else {
[self.delegate didTakeAccessToken:session.accessTokenData.accessToken];
}
}];
}
我找不到我的錯誤。 什麼是accesToken
的最佳途徑?謝謝。
如果'openActiveSessionWithPermissions聲明:'看起來'openActiveSessionWithReadPermissions陌生和完成處理程序:'會被多次調用。閱讀文件。 – kelin 2014-08-29 13:36:49