objective c - Facebook login happening when clicking Logout in iOS? -
i have viewcontroller shows fb button signing , taking user next viewcontroller.
i have made changes in info.plist
appdelegate.m
#import "appdelegate.h" #import <parse/parse.h> #import <fbsdkcorekit/fbsdkcorekit.h> #import <fbsdkloginkit/fbsdkloginkit.h> #import <parsefacebookutilsv4/pffacebookutils.h> - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { // override point customization after application launch. // initialize parse. [parse setapplicationid:@"parse_app_id" clientkey:@"parse_client_key"]; [pffacebookutils initializefacebookwithapplicationlaunchoptions:launchoptions]; [fbsdkloginbutton class]; // [optional] track statistics around application opens. [pfanalytics trackappopenedwithlaunchoptions:launchoptions]; // return [[fbsdkapplicationdelegate sharedinstance] application:application didfinishlaunchingwithoptions:launchoptions]; return yes; } - (void)applicationdidbecomeactive:(uiapplication *)application { [fbsdkappevents activateapp]; } - (bool)application:(uiapplication *)application openurl:(nsurl *)url sourceapplication:(nsstring *)sourceapplication annotation:(id)annotation { return [[fbsdkapplicationdelegate sharedinstance] application:application openurl:url sourceapplication:sourceapplication annotation:annotation]; }
storyboard
- add uibutton , change class fbsdkloginbutton
- add segue uibutton next viewcontroller , name fbsegue
- add ibaction uibutton , call fbloginaction
loginviewcontroller.m
#import "loginviewcontroller.h" #import <parse/parse.h> #import <fbsdkcorekit/fbsdkcorekit.h> #import <fbsdkloginkit/fbsdkloginkit.h> #import <parsefacebookutilsv4/pffacebookutils.h> - (ibaction)fbloginaction:(id)sender { [self fblogin]; } - (void)fblogin { nsarray *permissions = @[@"public_profile", @"email"]; [pffacebookutils logininbackgroundwithreadpermissions:permissions block:^(pfuser *user, nserror *error) { if (!user) { nslog(@"uh oh. user cancelled facebook login."); } else if (user.isnew) { nslog(@"user signed , logged in through facebook!"); [self performseguewithidentifier:@"fbsegue" sender: self]; } else { nslog(@"user logged in through facebook!"); [self performseguewithidentifier:@"fbsegue" sender: self]; } }]; }
problems
when click login facebook button on ios simulator, safari page authorize app. when that, still see loginviewcontroller facebook button changed logout.
when click logout button, taken facebook on safari message have authorized app , taken app. there option in bottom logout , cancel, in clicking either, taken next view controller.
any guidance please? understand since have not done under viewdidload method, user won't logged in , taken next view controller when app starts.
i think using fbsdkloginbutton in wrong way.
from documentation on https://developers.facebook.com/docs/reference/ios/current/class/fbsdkloginbutton/
fbsdkloginbutton works [fbsdkaccesstoken currentaccesstoken] determine display, , automatically starts authentication when tapped (i.e., not need manually subscribe action targets).
so shouldn't have use ibaction , can using uiview instead of uibutton fbsdkloginbutton
Comments
Post a Comment