我是iOS(原生)世界的初学者,我的演示应用中的Facebook身份验证存在一个奇怪的问题。
我已按照教程配置了.plist文件,其中包含以下键:
FacebbokAppID: <myappid>
FacebookDisplayName: a name
Url types (array)
Item 0 (dictionary)
Url Schemes (Array)
Item 0 (String): fb<myappid>
其中<myappid>
是Facebook网站上已注册应用的数字应用ID。
现在,我使用以下代码执行登录:
- (void) facebookLoginLogout
{
// If the session state is any of the two "open" states when the button is clicked
if (FBSession.activeSession.state == FBSessionStateOpen
|| FBSession.activeSession.state == FBSessionStateOpenTokenExtended) {
// Close the session and remove the access token from the cache
// The session state handler (in the app delegate) will be called automatically
[FBSession.activeSession closeAndClearTokenInformation];
// If the session state is not any of the two "open" states when the button is clicked
} else {
// Open a session showing the user the login UI
// You must ALWAYS ask for basic_info permissions when opening a session
[FBSession openActiveSessionWithReadPermissions:@[@"basic_info", @"friends_online_presence"]
allowLoginUI:YES
completionHandler:
^(FBSession *session, FBSessionState state, NSError *error) {
// Retrieve the app delegate
AppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
// Call the app delegate's sessionStateChanged:state:error method to handle session state changes
[appDelegate sessionStateChanged:session state:state error:error];
}];
}
}
我已经定义了处理状态变化的方法:
- (void)sessionStateChanged:(FBSession *)session state:(FBSessionState) state error:(NSError *)error
{
NSLog(@"here?");
[..]
}
问题在于,在这种情况下永远不会调用此方法。
THE STRANGE POINT 是,如果我将Url types -> Item 0 -> Url Schemes -> Item 0
值更改为不同的值,则会调用该方法!
任何提示?提前谢谢。