2
我正在使用Xcode 7使用Facebook iOS idk v4.1編寫針對iOS7的應用程序。當我執行Facebook登錄時,FBSDKLoginButton回調中的[FBSDKAccessToken currentAccessToken]仍然爲零。我已經嘗試了幾種SO解決方案來解決這個問題,但迄今爲止還沒有一種解決方案能夠解決此問題登錄Facebook之前iOS 9
我認爲問題出在我的appDelegate。這裏是我的代碼:
- (BOOL) application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
//for Facebook signin
if([[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:sourceApplication annotation:annotation])
{
return YES;
}
//for Google Signin on iOS 8 and earlier
else
{
NSDictionary* options = @{UIApplicationOpenURLOptionsSourceApplicationKey:sourceApplication, UIApplicationOpenURLOptionsAnnotationKey:annotation};
return [self application:application openURL:url options:options];
}
}
//iOS 9 and later
//for Google Signin
- (BOOL) application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString *,id> *)options
{
if ([[[NSUserDefaults standardUserDefaults] objectForKey:UDLoginType] integerValue] == ltGoogle)
{
return [[GIDSignIn sharedInstance] handleURL:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey] annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];
}
else
{
return YES;
}
}
當我的應用程序從Facebook返回時,應用程序:openURL:options(iOSv9 +)被調用。該方法不包含對Facebook SDK的調用。在應用程序中有一個對Facebook SDK的調用:openURL:sourceApplication:註解(iOSv8-),但我不知道如何將它翻譯爲iOSv9調用,就像Google一樣。據我所知,在Facebook登錄後沒有處理登錄URL。我究竟做錯了什麼?
感謝