objective c - Unable to get the access token through FBSDKLoginKit when I am try to login in iOS sdk -


i using facebook sdk share text on facebook unable access token when try login. login done did not access token. without access token unable share text on facebook. code follows

fbsdkloginmanager *login = [[fbsdkloginmanager alloc] init]; [login loginwithreadpermissions:@[@"public_profile"] handler:^(fbsdkloginmanagerloginresult *result, nserror *error) {   if ([result.token hasgranted:@"publish_actions"]) {     [[[fbsdkgraphrequest alloc]       initwithgraphpath:@"me/feed"       parameters: @{ @"message" : @"hello world"}       httpmethod:@"post"]      startwithcompletionhandler:^(fbsdkgraphrequestconnection *connection, id result, nserror *error) {          if (!error) {              nslog(@"post id:%@", result[@"id"]);          }      }]; }  if (error) {     // process error } else if (result.iscancelled) {      // handle cancellations } else {     // if ask multiple permissions @ once,     // should check if specific permissions missing     if ([result.grantedpermissions containsobject:@"email"]) {         // work     } } 

}];

i result in handler block of fbsdkloginmanager object without error not contain token or other data

output follow

enter image description here

please tell me how resolve problem thanks

try code. based on facebook sdk version 4.0

appdalegate.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]; } 

viewcontroller.m

- (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];                  [login logout];              }          }      }]; }  -(void)fetchuserinfo {     if ([fbsdkaccesstoken currentaccesstoken])     {         nslog(@"token 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);              }          }];      }  } 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

c# - Retrieve google contact -

javascript - How to insert selected radio button value into table cell -