Featured post
ios - FBSessionDelegate methods not firing -
i'm attempting implement latest facebook connect sdk , i'm having troubles. reason delegate callbacks fbsessiondelegate
protocol not being fired. i've followed instructions on git facebook page , tried mimic facebook sample app no luck. i'm going crazy here i'm gonna post code , maybe see silly i've missed.
#import <foundation/foundation.h> #import "fbconnect.h" @interface facebookwrapper : uiviewcontroller <fbsessiondelegate, fbrequestdelegate, fbdialogdelegate>{ facebook* _facebook; nsarray* _permissions; } @property(readonly) facebook *facebook; - (void)login; @end #import "facebookwrapper.h" static nsstring* kappid = @"1234455667778"; @implementation facebookwrapper @synthesize facebook = _facebook; - (id)init { if (self = [super init]) { _permissions = [[nsarray arraywithobjects: @"read_stream", @"offline_access",nil] retain]; _facebook = [[facebook alloc] initwithappid:kappid]; } return self; } - (void)dealloc { [_facebook release]; [_permissions release]; [super dealloc]; } - (void)login { [_facebook authorize:_permissions delegate:self]; } - (void)fbdidlogin { nslog(@"did log in"); } - (void)fbdidnotlogin:(bool)cancelled { nslog(@"failed log in"); } - (void)fbdidlogout { nslog(@"logged out"); }
and call class,
facebookwrapper *fw = [[facebookwrapper alloc] init]; [fw login];
the behavior i'm seeing on phone expected. facebook app launches on init , permissions requested. phone brings app foreground delegates fbsessiondelegate
never fired. i've tried in facebook sample app using app id , worked fine. have no idea difference is.
i figured out problem. in app delegate need override handleopenurl.
- (bool)application:(uiapplication *)application handleopenurl:(nsurl *)url { return [[facebookwrapper facebook] handleopenurl:url]; }
if you're creating wrapper class you'll need instance of in app delegate can call hanleopenurl method in facebook class. notice there public readonly property facebook instance in facebookwrapper class can call handlopenurl.
by doing app know continue when returns getting permissions inside of facebook app.
- Get link
- X
- Other Apps
Comments
Post a Comment