ios - Parse - Facebook users being recreated everytime -


i'm using parse.com + facebook user , i'm noticing unusual has not been happening previously. user creates account via facebook, logs in, logs out, logs in, logs out, , when try logging in, user gets deleted , user gets created. why be?

here signup/signin code:

-(ibaction)facebooksignin:(id)sender{     clgeocoder *geo = [[clgeocoder alloc] init];     if(![cllocationmanager locationservicesenabled] || [cllocationmanager authorizationstatus] == kclauthorizationstatusdenied ){         uialertview *locationalert = [[uialertview alloc]initwithtitle:@"oops!" message:@"you must have location services enabled app work properly" delegate:self cancelbuttontitle:nil otherbuttontitles:@"okay", nil];         [locationalert show];     }else{            [pffacebookutils loginwithpermissions:_permissions block:^(pfuser *auser, nserror *suerror) {             if(!auser){                 nslog(@"not fbook user because %@",[suerror description]);                  if([[[suerror userinfo] objectforkey:@"com.facebook.sdk:errorloginfailedreason"] isequaltostring:@"com.facebook.sdk:systemlogindisallowedwithouterror"]){                  uialertview *alert = [[uialertview alloc]initwithtitle:@"error" message:@"looks have facebook authentication disabled! go settings > facebook > myswapp , turn switch on"delegate:nil cancelbuttontitle:nil otherbuttontitles:@"okay", nil];                     [alert show];                  }                 else{                  uialertview  *alert = [[uialertview alloc]initwithtitle:@"error signing in/logging in" message:[suerror localizeddescription] delegate:nil cancelbuttontitle:nil otherbuttontitles:@"okay", nil];                     [alert show];                 }              }             else if(auser.isnew){                  nslog(@"user new");                  [[fbrequest requestforme] startwithcompletionhandler:                  ^(fbrequestconnection *connection,                  nsdictionary<fbgraphuser> *user,                  nserror *fberror) {                  if (!fberror) {                   nslog(@"facebook request succeeded");                   nsstring *email = [user objectforkey:@"email"];                  [auser setemail:email];                   pfquery *g = [pfquery querywithclassname:@"counter"];                  pfobject *cool = [g getobjectwithid:@"gpkdgnhwhw"];                  [cool incrementkey:@"users"];                  [cool saveeventually];                  nsstring *username = [nsstring stringwithformat:@"blahblah%d",[[cool objectforkey:@"users"] intvalue]];                  [auser setusername:username];                  pfinstallation *installation = [pfinstallation currentinstallation];                  [installation setobject:auser forkey:@"user"];                   [auser setobject:@no forkey:@"text"];                  [auser setobject:@yes forkey:@"snew"];                  [auser setobject:@"all" forkey:@"prefstate"];                  [auser setobject:@"all" forkey:@"prefcat"];                      [auser setobject:@yes forkey:@"fnew"];                  _type = @"facebook";                   nslog(@"right before geopoint search....");                   [pfgeopoint geopointforcurrentlocationinbackground:^(pfgeopoint *geopoint, nserror *error) {                  if(!error){                  nslog(@"got current geopoint!");                  cllocation *mylocation = [[cllocation alloc]initwithlatitude:geopoint.latitude longitude:geopoint.longitude];                  [geo reversegeocodelocation:mylocation completionhandler:^(nsarray *placemarks, nserror *error) {                  if(!error){                  clplacemark *pl = placemarks[0];                   nsstring *zip = [pl.addressdictionary objectforkey:(nsstring *)kabpersonaddresszipkey];                  nsstring *city = [pl.addressdictionary objectforkey:(nsstring *)kabpersonaddresscitykey];                  nsstring *state = [pl.addressdictionary objectforkey:(nsstring *)kabpersonaddressstatekey];                  if(city == nil ||state ==nil){                  nslog(@"city or state nil");                  if(city==nil){                  nslog(@"city nil");                  }                  if(state==nil){                  nslog(@"state nil");                  }                  }                  [auser setobject:city forkey:@"city"];                  [auser setobject:state forkey:@"state"];                  [auser setobject:zip forkey:@"zip"];                  [auser setobject:geopoint forkey:@"geopoint"];                  [auser setobject:@no forkey:@"pref"];                  [auser setobject:@20 forkey:@"radius"];                      [auser setobject:@0 forkey:@"postcount"];                   [auser saveinbackgroundwithblock:^(bool succeeded, nserror *perror) {                  if(!perror && succeeded){                   [self performseguewithidentifier:@"registerme" sender:self];                                          }                  else{                       ccalertview *erroralert = [[ccalertview alloc]initwithtitle:@"oops!" message:[nsstring stringwithformat:@"%@. if have registered, please login regularly , go settings tab , switch on \"link facebook\".",[[perror userinfo] objectforkey:@"error"]]];                      [erroralert addbuttonwithtitle:@"okay" block:^{                          [auser deleteinbackground];                      }];                      [erroralert show];                  }                  }];                  }                  else{                      ccalertview *erroralert = [[ccalertview alloc]initwithtitle:@"error getting facebook data" message:[[fberror userinfo] objectforkey:@"error"]];                      [erroralert addbuttonwithtitle:@"okay" block:^{                          [auser deleteinbackground];                      }];                      [erroralert show];                   }                  }];                  }                  else{                 ccalertview *erroralert = [[ccalertview alloc]initwithtitle:@"facebook sign in/sign up" message:[[suerror userinfo] objectforkey:@"error"]];                      [erroralert addbuttonwithtitle:@"okay" block:^{                           [auser deleteinbackground];                       }];                    [erroralert show];                      nsstring *ciid = [[pfinstallation currentinstallation] objectid];                      [pfcloud callfunctioninbackground:@"logerror" withparameters:@{@"installation":ciid,@"message":[suerror description],@"place":@"facebook sign in/sign up"} block:^(id object, nserror *error) {                          if(error){                              pfobject * errorobj = [pfobject objectwithclassname:@"error"];                              [errorobj setobject:ciid forkey:@"installation"];                              [errorobj setobject:[suerror description] forkey:@"message"];                              [errorobj setobject:@"facebook sign in/sign up" forkey:@"place"];                              [errorobj saveeventually];                          }                      }];                  }                  }];                    }                   }];                       }             else{                 nslog(@"user old");                 [self performseguewithidentifier:@"showmain" sender:self];                        }          }];          }    } 

and here logout code:

- (ibaction)gobacknow:(id)sender {     nslog(@"gobacknow called");     [pfuser logout];      [self.navigationcontroller poptorootviewcontrolleranimated:yes];  } 

you can try add more stuff logout method. e.g.

[fbsession.activesession closeandcleartokeninformation]; [fbsession.activesession close]; [fbsession setactivesession:nil];  pfinstallation *installation = [pfinstallation currentinstallation]; installation[@"user"] = [nsnull null]; [installation saveinbackground]; 

also remember [installation saveinbackground]; in example


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -