Not Getting Email and Public Profile Using Facebook 4.4.0 Sdk

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.

did not get public profile information and email by Facebook java script sdk

FB.api('/me', {fields: 'name,email,...'}, function(response) {
console.log(JSON.stringify(response));
});

It is called "Declarative Fields", you need to specify the fields you want to get.

Changelog: https://developers.facebook.com/docs/apps/changelog#v2_4

Of course you need to ask for the email permission in the authorization process too.

not Getting user's email Personal info from Facebook in iOS 8

You will have to pass paramenter email to fetch user_email through Facebook:

///Add This line
NSMutableDictionary* parameters = [NSMutableDictionary dictionary];
[parameters setValue:@"id,name,email" forKey:@"fields"];

[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:parameters] <--------- This line

startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error)
{

}

Velruse Facebook profile has no email

Facebook states that the email is information approved by default for my app

The email scope/permission does not require login review, but you do have to request it as part of the authentication flow for the user to be prompted to share it with your application.

The user may reject your request for access to their email. Additionally, some users log in with a cell phone number and may not have an email address on file with Facebook at all.

Short answer: some users won't give or have an email. Your application needs to account for this.

Why can't I get a user's first name from a GraphRequest?

As per official documents your login for accessing public_profile permission should look like :

 LoginManager.getInstance().logInWithReadPermissions(Login.this, Arrays.asList("public_profile", "email"));

To get Profile Info :

 private void getFbDetails(final AccessToken accessToken) {
GraphRequest request = GraphRequest.newMeRequest(accessToken,
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(
JSONObject object,
GraphResponse response) {

// Toast.makeText(Login.this, object.toString(), Toast.LENGTH_LONG).show();
Log.v("FB Details", object.toString());
if (object != null) {
name_fb = object.optString("name");
email_fb = object.optString("email");
}
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,first_name, last_name, email,link");
request.setParameters(parameters);
request.executeAsync();
}

Facebook Activity not loading correctly in facebook-sdk 4.4.0

Try this one

LoginButton loginButton;
CallbackManager callbackManager;

FacebookSdk.sdkInitialize(getApplicationContext());
callbackManager = CallbackManager.Factory.create();

loginButton = (LoginButton) findViewById(R.id.login_button);
loginButton.setReadPermissions(Arrays.asList("public_profile", "user_friends", "email"));

loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {

Profile profile = Profile.getCurrentProfile();
profile.getProfilePictureUri(315, 315);
GraphRequest request = GraphRequest.newMeRequest(loginResult.getAccessToken(),
new GraphRequest.GraphJSONObjectCallback() {
@Override
public void onCompleted(JSONObject object, GraphResponse response) {
Log.v("LoginActivity", response.toString());
}
});
Bundle parameters = new Bundle();
parameters.putString("fields", "id,name,email");
request.setParameters(parameters);
request.executeAsync();
}

@Override
public void onCancel() {
}

@Override
public void onError(FacebookException e) {
e.printStackTrace();
}
});

and override below method

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
callbackManager.onActivityResult(requestCode, resultCode, data);
}

and define this in menifest

<activity
android:name="com.facebook.FacebookActivity" android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent.NoTitleBar"/>


Related Topics



Leave a reply



Submit