Not getting Facebook sdk 3.2 birthday on iOS

I used Facebook sdk 3.2 in my application, I want to get all the details of my profile, but it does not give me a birthday.

I used the code:

[FBRequestConnection
     startForMeWithCompletionHandler:^(FBRequestConnection *connection,
                                       id<FBGraphUser> user,
                                       NSError *error) {
         if (!error) {


         }
     }];

Can someone explain where I'm wrong here?

Any help would be appreciated.

Thnaks in advance.

+4
source share
3 answers

After version 3.13, if you request permission other than public_profile, email and user_friends, then you need to send your application for verification, otherwise you will not receive it, therefore you cannot receive user_birthday. As written here

, , public_profile, email user_friends, Facebook, , . . " ". , , . , 30 2014 , .

+6
NSArray *arrFBPermissions = [[NSArray alloc] initWithObjects: @"user_birthday",@"email",nil];
[FBSession openActiveSessionWithReadPermissions:arrFBPermissions
                                   allowLoginUI:YES
                              completionHandler:
 ^(FBSession *session, FBSessionState state, NSError *error) {

     if (error == nil) {

         [FBRequestConnection startWithGraphPath:@"me?fields=id,name,birthday" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {

             if (error == nil) {

                 NSLog(@"FB user detail %@",result);

             }else {

                 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:[NSString stringWithFormat:@"Following error occured:%@",error] delegate:nil cancelButtonTitle:@"dismiss" otherButtonTitles: nil];
                 [alert show];

             }
         }];

     }else {

         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:[NSString stringWithFormat:@"Following error occured:%@",error] delegate:nil cancelButtonTitle:@"dismiss" otherButtonTitles: nil];
         [alert show];

     }
 }];

FacebookAppID, URL, , facebook.

You can check it on developer.facebook.com graph api tool

+1

FBGraphUser

[[FBRequest requestForMe] startWithCompletionHandler:
     ^(FBRequestConnection *connection,
       NSDictionary<FBGraphUser> *user,
       NSError *error) {
         if (!error) {
             NSString *firstName = user.first_name;
             NSString *lastName = user.last_name;
             NSString *bDay = user.birthday;
             NSString *facebookId = user.id;
             NSString *email = [user objectForKey:@"email"];
             NSString *imageUrl = [[NSString alloc] initWithFormat: @"http://graph.facebook.com/%@/picture?type=large", facebookId];
             NSLog(@"%@, %@ , %@ , %@ ,%@ ,%@",bDay,firstName,lastName,facebookId,email,imageUrl);
         }
     }];
0

Source: https://habr.com/ru/post/1543331/


All Articles