We've built an iOS app that uses the Facebook SDK. Unfortunately, our client has asked that we disable backgrounding in the app and this means t开发者_运维百科hat the Facebook single-sign on (SSO) scheme doesn't work for us (as our app now starts from scratch when it is launched after the login/authorisation in the Facebook app).
So the question is: can we disable SSO in the Facebook iOS SDK such that it behaves like it did in older SDK versions with the Facebook login/ authorization happening within an in-app web-view?
Open Facebook.m file in FBconnect library and find:
- (void)authorize:(NSArray *)permissions
delegate:(id<FBSessionDelegate>)delegate {
set:
[self authorizeWithFBAppAuth:NO safariAuth:NO];
And FBconnect will authorize only with inside popup...
I don't know you can disable sso or not but i have a trick to do this.(every time need credential for login on facebook).
write these line in appDelegate's didFinishLaunchingWithOptions
method
NSHTTPCookieStorage* cookies = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (NSHTTPCookie* cookie in
[[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]) {
NSString *domainStr=(NSString *)[cookie domain];
NSLog(@"%@",domainStr);
if([domainStr isEqualToString:@".facebook.com" ])
{
[cookies deleteCookie:cookie];
}
[self authorizeWithFBAppAuth:NO safariAuth:NO];
you can save the state of your app before calling the facebook authentification process. but if the FB app is on the phone of your user, the
[facebook authorize:permissions delegate:self]
will redirect you to it.
But if you only have basic needs, you could use the webview part of the FB SDK. Using:
[facebook authorize:permissions delegate:self]
will make FB SDK displays a webview which will take care of the authorization process.
精彩评论