Active Facebook access token iOS error -
i'm trying integrate facebook ios app running snag.
when first ran code worked seems in facebook cache causing error: "an active access token must used query information current user."
i use these 2 functions attempt upload photo:
+(bool)loginandpostimage:(uiimage*)image andmessage:(nsstring*)message {      nsarray *permissions = [nsarray arraywithobjects:@"publish_stream", nil];     [fbsession.activesession closeandcleartokeninformation];     return [fbsession  openactivesessionwithpublishpermissions:permissions                                               defaultaudience:fbsessiondefaultaudienceonlyme                                                  allowloginui:yes                                             completionhandler:             ^(fbsession *session, fbsessionstate state, nserror *error) {                 [self sessionstatechanged:session                                     state:state                                     error:error];                 if(error) {                     uialertview *alert = [[uialertview alloc] initwithtitle:@"error" message:@"problem connecting facebook" delegate:nil cancelbuttontitle:@"okay" otherbuttontitles:nil];                     [alert show];                 } else {                     [self postimage:image andmessage:message];                 }             }]; }  +(void)postimage:(uiimage*)image andmessage:(nsstring*)message {      nslog(@" access token description: %@",[[fbsession activesession] accesstoken].description);      [fbrequestconnection startforuploadphoto:image completionhandler:^(fbrequestconnection *connection, id result, nserror *error) {         if (!error) {             [[[uialertview alloc] initwithtitle:@"result"                                         message:@"your update has been posted facebook!"                                        delegate:self                               cancelbuttontitle:@"sweet!"                               otherbuttontitles:nil] show];         } else {             [[[uialertview alloc] initwithtitle:@"error"                                         message:@"yikes! facebook had error.  please try again!"                                        delegate:nil                               cancelbuttontitle:@"ok"                               otherbuttontitles:nil] show];             nslog(@"%@", error);         }      }]; }   when query description of active token description, null. guess while fbsession openactivesessionwithpublishpermissions:defaultaudience:allowloginui:completionhandler: doesn't return error, i'm not generating token?
any suggestions how can further debug error? have followed additional setup outlined facebook developer page.
it's session not opened. shouldn't call
[self postimage:image andmessage:message];   unless there's no error ,
(state == fbsessionstateopen)   to debug further, take @ value of "state" variable , see is.
another thing aware of is, if first time user logging app, can't ask publish/write permissions. must ask read permissions , later on, in context, request publish permissions. if ask publish permissions initially, should error. you're not getting error, may not case.
Comments
Post a Comment