Iphone facebook connect example calls safari. I don't want to use safari. How to fix this problem.
问题:
回答1:
I'm not sure if this is kosher but I commented out lines 131-145 in Facebook.m
to pop open a UIWebView
instead of opening up the login screen in Safari. Seems to work fine for me...
回答2:
Donkim's suggestion above worked well for me using the 1/31/2011 commit of the SDK. Another option is to look for each call to "authorizeWithFBAppAuth:safariAuth:" in Facebook.m. You can change the second argument from YES to NO on lines 221, 267, and 274.
回答3:
Despite the fact that it open safari and that's ugly, you benefit from the SSO which is a great feature. If any other app is using FBConnect, you user will be automatically connected to yours. And if the facebook app is present, its even better, the login is done through the facebook app and no longer in safari.
So I suggest you keep it that way !
I agree that the whole process should be a bit improved and at least not open a new safari tab every time you connect ! Patience...
回答4:
If user has Facebook application for iphone, then it won't open safari. It will open directly Facebook App
回答5:
The problem with all these solutions is you lose a consistent auth_token. So if you need to do manual graph requests later on in your code by passing the auth_token in the URL, you simply can't.
回答6:
Set safariAuth:NO on [self authorizeWithFBAppAuth:YES safariAuth:NO]; (facebook.m:221)
回答7:
For anyone using a newer Facebook iOS SDK (not sure which version added it), you can use the dialog:@"oauth" ...
method (doc). As others have said, you give up SSO, but for use cases like mine (an OpenGL game), I find the overlay preferable to switching to a different app.
回答8:
File: Facebook.m | Starts at: line #220 authorizeWithFBAppAuth:safariAuth:
| Add boolean trySafariAuth = NO;
to line #223
/**
* A private function for opening the authorization dialog.
*/
- (void)authorizeWithFBAppAuth:(BOOL)tryFBAppAuth
safariAuth:(BOOL)trySafariAuth {
trySafariAuth = NO;
// more code allow blow this, but im too lazy to show it
// so please just change the boolean...
}
回答9:
Change following method as follows in facebook.m
- (void)authorize:(NSArray *)permissions
delegate:(id<FBSessionDelegate>)delegate {
[_permissions release];
_permissions = [permissions retain];
_sessionDelegate = delegate;
[self authorizeWithFBAppAuth:NO safariAuth:NO];
// [self authorizeWithFBAppAuth:NO safariAuth:YES];
}