How to "Rerequest" Email Permission Using Facebook iOS Sdk 4.X

How to “rerequest” email permission using Facebook iOS SDK 4.x?

I resolved issue by recalling the method :

[login logInWithReadPermissions:@[@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)

I need to pass auth_type: 'rerequest' while requesting again and i get it in the documentation of this method i get the description :

Use this method when asking for read permissions. You should only ask
for permissions when they are needed and explain the value to the
user. You can inspect the result.declinedPermissions to also provide
more information to the user if they decline permissions.

If [FBSDKAccessToken currentAccessToken] is not nil, it will be
treated as a reauthorization for that user and will pass the
"rerequest" flag to the login dialog.

just the problem was i was calling logout Method of FbSDKLoginManager class. This will clear the token and it will takes it as the old permission not re-requested permission.

How to rerequest email permission using Facebook iOS SDK 3.21.1?

You can just call the [FBSession requestNewReadPermissions:completionHandler:] method. It will automatically add the rerequest auth_type for you.

Facebook oAuth: Force email permission

They are using an old App created before end of April 2014, it was different back then. You can´t force it anymore, you can only check if the user authorized the permissions after login, with the return_scopes flag, for example:

https://developers.facebook.com/docs/reference/javascript/FB.login/v2.2

Manage permissions with Facebook JS SDK

If the user authorized your App already, you can just delete the permissins BEFORE FB.login. FB.getLoginStatus re-authorizes the user anyway. So the first FB.login is not needed, but the API call for deleting permissions is ansynchronous, that is why browser block the second FB.login call.
Just delete the permissions right after FB.getLoginStatus and only do FB.login in the changePermissions function.

Example with FB.getLoginStatus: https://www.devils-heaven.com/facebook-javascript-sdk-login/

Unable to get the email id of the User when Log-in with Facebook SDK in iOS

You can try this code. Based on Facebook SDK version 4.0. It is modified in 4.0 when compared with the older version.

In App delegate.m

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [[FBSDKApplicationDelegate sharedInstance] application:application
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
}

In viewController.m file

- (IBAction)btnFacebookPressed:(id)sender {
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:@[@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
{
if (error)
{
// Process error
}
else if (result.isCancelled)
{
// Handle cancellations
}
else
{
if ([result.grantedPermissions containsObject:@"email"])
{
NSLog(@"result is:%@",result);
[self fetchUserInfo];
}
}
}];
}

-(void)fetchUserInfo
{
if ([FBSDKAccessToken currentAccessToken])
{
NSLog(@"Token is available : %@",[[FBSDKAccessToken currentAccessToken]tokenString]);

[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"id, name, link, first_name, last_name, picture.type(large), email, birthday, bio ,location ,friends ,hometown , friendlists"}]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error)
{
NSLog(@"resultis:%@",result);
}
else
{
NSLog(@"Error %@",error);
}
}];

}

}

In viewdidload method call this function fetchUserInfo

[self fetchUserInfo];

By calling this method you will get the access token after login and you want to clearly specify in permission about the email. by this method you can able to fetch the email of the user. enjoy

Error retrieving email address using facebook SDK

Ok, I have got answer to my problem.
If you are using Facebook's Button code then You have to add extra permissions as an array. What i was doing was that calling the Login Function manually with permissions but forgot to add permissions as a scope in button code.

<div class="fb-login-button" data-max-rows="5" data-size="xlarge" data-show-faces="true" scope=['email'] data-auto-logout-link="true"></div>

Not getting Email and public profile using Facebook 4.4.0 SDK

With Facebook 4.4 SDK there is a slight change.
You must have to request the parameter with the FBSDKGraphRequest which you want from Facebook account.

In your code there is nil in parameters :

Update your code with the parameters like as :

[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"id, name, link, first_name, last_name, picture.type(large), email, birthday, bio ,location , friends ,hometown , friendlists"}]

If you want to login with Facebook with the use of Custom Button then you can use the complete code as follows :

- (IBAction)btnFacebookPressed:(id)sender {
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
login.loginBehavior = FBSDKLoginBehaviorBrowser;
[login logInWithReadPermissions:@[@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error)
{
if (error)
{
// Process error
}
else if (result.isCancelled)
{
// Handle cancellations
}
else
{
if ([result.grantedPermissions containsObject:@"email"])
{
NSLog(@"result is:%@",result);
[self fetchUserInfo];
[login logOut]; // Only If you don't want to save the session for current app
}
}
}];
}
-(void)fetchUserInfo
{
if ([FBSDKAccessToken currentAccessToken])
{
NSLog(@"Token is available : %@",[[FBSDKAccessToken currentAccessToken]tokenString]);

[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:@{@"fields": @"id, name, link, first_name, last_name, picture.type(large), email"}]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error)
{
NSLog(@"resultis:%@",result);

}
else
{
NSLog(@"Error %@",error);
}
}];
}
}

I hope it will work for you.



Related Topics



Leave a reply



Submit