简体   繁体   中英

Facebook SDK 3.0 Login for iOS apps that do not run in the background

I am in the process of implementing Facebook SDK 3.0 in my iOS app. Previously, I was able to login using a webview from within my app, but it appears that that option is no longer available in SDK 3.0.

My app does not run in the background (that is something that I am not going to change at this point). I currently launch Facebook from a view controller that is not the root controller (which is shown when the app is first launched); and I use a completion handler to finish the Facebook request when the login completes successfully.

The problem is that when the Facebook login is launched, it takes the user out of the app now; the completion handler result is never called, since the app was terminated. So the user is left on the rootController, with no results after logging in.

Is there any way to possibly login to Facebook from within the app in SDK 3.0?

If not, is there a workaround that will allow me to keep my app from running in the background?

You can force the login in a web view like this :

FBSession *mySession = [[FBSession alloc] initWithAppID:myAppID 
                                            permissions:myPermissions 
                                        urlSchemeSuffix:myUrlSchemeSuffix 
                                     tokenCacheStrategy:nil];
[FBSession setActiveSession:mySession];
[mySession openWithBehavior:FBSessionLoginBehaviorForcingWebView
          completionHandler:myCompletionHandler];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM