- 我想在登錄時打開Facebook應用程序,該應用程序已經安裝在設備中進行登錄驗證,但始終在Safari瀏覽器中打開。
- Facebook的按鈕,點擊iOS:使用Facebook登錄並打開本機Facebook應用程序
-(void)loginButtonClicked
{
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
// [login setLoginBehavior:FBSDKLoginBehaviorNative];
[login logInWithReadPermissions:@[@"email"] fromViewController:self handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
{
if (error)
{
NSLog(@"Login process error");
}
else if (result.isCancelled)
{
NSLog(@"User cancelled login");
}
else
{
NSLog(@"Login Success");
if ([result.grantedPermissions containsObject:@"email"])
{
NSLog(@"result is:%@",result);
[self fetchUserInfo];
}
else
{
// [SVProgressHUD showErrorWithStatus:@"Facebook email permission error"];
}
}
}];
}
}
,尤其是圓形獲取用戶信息
-(void)fetchUserInfo
{
if ([FBSDKAccessToken currentAccessToken])
{
NSLog(@"Token is available : %@",[[FBSDKAccessToken currentAccessToken]tokenString]);
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"id, name, email"}]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error)
{
NSLog(@"results:%@",result);
NSString *email = [result objectForKey:@"email"];
NSString *userId = [result objectForKey:@"id"];
if (email.length >0)
{
NSString *accessToken = [[FBSDKAccessToken currentAccessToken] tokenString];
[ref authWithOAuthProvider:@"facebook" token:accessToken
withCompletionBlock:^(NSError *error, FAuthData *authData)
{
if (error)
{
NSLog(@"Login failed. %@", error);
}
else
{
NSLog(@"Logged in! %@", authData);
//Start you app Todo
}
else
{
NSLog(@"Facebook email is not verified");
}
}
else
{
NSLog(@"Error %@",error);
}
}];
}
- 我想打開Facebook應用與Facebook的登錄。
http://stackoverflow.com/questions/32566734/native-facebook-app-does-not-open-with-facebook-login-in-ios-9 檢查此鏈接。 –
此代碼已經使用,但不是在fb應用程序中打開,總是瀏覽器,我用新的sdk 4x –
我不是在這個組中 –