Saturday, 15 May 2010

objective c - How to go on a particular view when user is already logged in via Facebook in ios app? -



objective c - How to go on a particular view when user is already logged in via Facebook in ios app? -

i building app need facebook login integration.my app contain tour 4 images , facebook button login , i’m using storyboards.

i implemented facebook login.

i facing problem want when user login goes next view , after closing app when user opens app 1 time again should on next view not on tour screens.

i have tried segue, first user when logged in goes next view when user come after closing app user tour page 1 time again don't want,but happening right when user click on facebook button user able go next view.

this code:

- (void)viewdidload { [super viewdidload]; nsstring *verify_status = [[nsuserdefaults standarduserdefaults]stringforkey:@"verify_status"]; if ([verify_status isequaltostring:@"y"]) { _pageimages = @[@"playo.jpg", @"playo.jpg", @"playo.jpg", @"playo.jpg"]; self.pageviewcontroller = [self.storyboard instantiateviewcontrollerwithidentifier:@"pageviewcontroller"]; self.pageviewcontroller.datasource = self; pagecontentviewcontroller *startingviewcontroller = [self viewcontrolleratindex:0]; nsarray *viewcontrollers = @[startingviewcontroller]; [self.pageviewcontroller setviewcontrollers:viewcontrollers direction:uipageviewcontrollernavigationdirectionforward animated:no completion:nil]; self.pageviewcontroller.view.frame = cgrectmake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 30); [self addchildviewcontroller:_pageviewcontroller]; [self.view addsubview:_pageviewcontroller.view]; [self.pageviewcontroller didmovetoparentviewcontroller:self]; } else { // nil } } - (ibaction)fblogin:(id)sender { [[fbrequest requestforme] startwithcompletionhandler:^(fbrequestconnection *connection, nsdictionary<fbgraphuser> *user, nserror *error) { if (error) { nslog(@"error:%@",user.objectid); } else { nsstring *usernamee; nslog(@"fb user first name:%@",user.first_name); usernamee=user.first_name; nslog(@"fb user lastly name:%@",user.last_name); nslog(@"fb user birthday:%@",user.birthday); nslog(@"fb user location:%@",user.location); nslog(@"fb user username:%@",user.username); nslog(@"fb user gender:%@",[user objectforkey:@"gender"]); nslog(@"email id:%@",[user objectforkey:@"email"]); nslog(@"location:%@", [nsstring stringwithformat:@"location: %@\n\n", user.location[@"name"]]); userimageurl = [nsstring stringwithformat:@"https://graph.facebook.com/%@/picture?type=large", [user objectid]]; nslog(@"image=%@",userimageurl); [self performseguewithidentifier:@"afterlogin" sender: self]; nsstring *verifystatus=@"y"; //for know logged in [[nsuserdefaults standarduserdefaults]setobject:verifystatus forkey:@"verify_status"]; [[nsuserdefaults standarduserdefaults] synchronize]; } }]; } - (void)logout { [fbsession.activesession closeandcleartokeninformation]; [[nsuserdefaults standarduserdefaults] removeobjectforkey:@"verify_status"]; // if u need utilize }

help appreciated!

ios objective-c facebook uiviewcontroller uistoryboardsegue

No comments:

Post a Comment