IOS facebook login using Xcode 5.1 -
i have followed instructions integrate facebook login in ios here. worked , able login started showing blank white screen in safari browser(i'm testing on simulator). have cleared cache , and unblock cookies.please if knows solution.
below code used in loginviewcontroller:
#import "viewcontroller.h" #import <facebooksdk/facebooksdk.h> @interface viewcontroller () @property (strong, nonatomic) iboutlet fbprofilepictureview *profilepictureview; @property (strong, nonatomic) iboutlet uilabel *namelabel; @property (strong, nonatomic) iboutlet uilabel *statuslabel; @end @implementation viewcontroller - (void)viewdidload { [super viewdidload]; // additional setup after loading view, typically nib. fbloginview *loginview = [[fbloginview alloc] initwithreadpermissions:@[@"basic_info", @"email", @"user_likes"]]; loginview.frame = cgrectoffset(loginview.frame, (self.view.center.x - (loginview.frame.size.width / 2)), 5); loginview.delegate = self; [self.view addsubview:loginview]; } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } // method called when user information has been fetched - (void)loginviewfetcheduserinfo:(fbloginview *)loginview user:(id<fbgraphuser>)user { self.profilepictureview.profileid = user.id; self.namelabel.text = user.name; } // logged-in user experience - (void)loginviewshowingloggedinuser:(fbloginview *)loginview { self.statuslabel.text = @"you're logged in as"; } // logged-out user experience - (void)loginviewshowingloggedoutuser:(fbloginview *)loginview { self.profilepictureview.profileid = nil; self.namelabel.text = @""; self.statuslabel.text= @"you're not logged in!"; } // handle possible errors can occur during login - (void)loginview:(fbloginview *)loginview handleerror:(nserror *)error { nsstring *alertmessage, *alerttitle; // if user should perform action outside of app recover, // sdk provide message user, need surface it. // conveniently handles cases facebook password change or unverified facebook accounts. if ([fberrorutility shouldnotifyuserforerror:error]) { alerttitle = @"facebook error"; alertmessage = [fberrorutility usermessageforerror:error]; // code handle session closures happen outside of app // can take @ our error handling guide know more // https://developers.facebook.com/docs/ios/errors } else if ([fberrorutility errorcategoryforerror:error] == fberrorcategoryauthenticationreopensession) { alerttitle = @"session error"; alertmessage = @"your current session no longer valid. please log in again."; // if user has cancelled login, nothing. // can choose show user message if cancelling login result in // user not being able complete task had initiated in app // (like accessing fb-stored information or posting facebook) } else if ([fberrorutility errorcategoryforerror:error] == fberrorcategoryusercancelled) { nslog(@"user cancelled login"); // simplicity, sample handles other errors generic message // can checkout our error handling guide more detailed information // https://developers.facebook.com/docs/ios/errors } else { alerttitle = @"something went wrong"; alertmessage = @"please try again later."; nslog(@"unexpected error:%@", error); } if (alertmessage) { [[[uialertview alloc] initwithtitle:alerttitle message:alertmessage delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil] show]; } } @end
Comments
Post a Comment