Reputation: 506
I was wondering if anyone knew why the FBSessionDidSetActiveSessionNotification, FBSessionDidUnsetActiveSessionNotification, FBSessionDidBecomeOpenActiveSessionNotification or FBSessionDidBecomeClosedActiveSessionNotification never gets fired when I open a new FBSession session?
The only way I got to detect the FBSessionDidBecomeOpenActiveSessionNotification & FBSessionDidSetActiveSessionNotification is when I call [FBSession setActiveSession:]; explicitly.
Basically, I got something like that:
_session = [[FBSession alloc] initWithAppID: FACEBOOK_AppId
permissions: _facebookPermissions
defaultAudience: FBSessionDefaultAudienceOnlyMe
urlSchemeSuffix: nil
tokenCacheStrategy: nil];
[_session openWithCompletionHandler:^(FBSession *session,
FBSessionState status,
NSError *error) {
[FBSession setActiveSession: _session];
// ...
}];
Is that normal that I have to call [FBSession setActiveSession:]; ?
Upvotes: 1
Views: 579
Reputation: 518
Use
+ (BOOL)openActiveSessionWithReadPermissions:(NSArray*)readPermissions
allowLoginUI:(BOOL)allowLoginUI
completionHandler:(FBSessionStateHandler)handler;
That is really just a helper function for doing something similar to what you're already doing, though. If you grab the source from the git repo, you can see what's going on in FBSession.m.
Upvotes: 1
Reputation: 2814
Try this:
+ (BOOL)openActiveSessionWithPermissions:(NSArray*)permissions
allowLoginUI:(BOOL)allowLoginUI
completionHandler:(FBSessionStateHandler)handler;
Upvotes: 1