Facebook SDK - iOS6 pop-up login cannot be rejected

In my iPhone app, I want the user to be able to share the link on Facebook.

When they click "share", I use the following code to login to Facebook using the new SDK 3.1, then use the FBRequestConnection in the completion handler (simple publish_action ).

 [FBSession openActiveSessionWithPublishPermissions:@[@"publish_actions"] defaultAudience:FBSessionDefaultAudienceFriends allowLoginUI:true completionHandler:^(FBSession *session, FBSessionState status, NSError *error) { // Now call FBRequestConnection to post in the stream }]; 

When the user has the Facebook application installed, he simply delegates the entrance to the application. However, when they do not, it opens the login page to the WebView.

In iOS 5, Mobile Safari opens:

enter image description here

My problem is in iOS 6, I get the same stream, but in a modal popup menu (on top of my application).

enter image description here

I have 2 problems with a popup:

1. Closure

It cannot be canceled or rejected. For comparison, the HelloFacebookSample application from the SDK has the same pop-up window, but with a cross button to close it.

enter image description here

NOTE: now resolved thanks to ravi, I did not have enough resource on the Facebook network, which contains a "close" image.

2. Acceptance of permissions

At the second stage of the pop-up window (see the screens above), pressing the OK button does nothing. Pressing the "X" button causes the completion handler to fail, which is fine, but nothing happens with Okay. Is this the right way to log in to Facebook with the SDK 3.1? Am I missing a callback to respond to a popup?

Additional explanations:

This only happens in iOS6 when the Facebook application is not installed and the Facebook account is not configured in iOS settings.

Thanks!

+6
source share
2 answers

I can not comment, because my reputation is less than 50, so I'm trying to point out my observations as an answer.

I also noticed this problem when using Facebook sdk3.1 on ios6 . In my case, I use the old-style facebook object creation and call [facebook authorize:permissions] on it, but I changed the source code to always use " FBSessionLoginBehaviorForcingWebView " so that my login always FBSessionLoginBehaviorForcingWebView through the website in the application.

In my case, I missed FBUserSettingsViewResources.bundle and FacebookSDKResources.bundle, so I could not see the cross (but I was able to click on this place and get a callback - (void)fbDidNotLogin:(BOOL)cancelled {).

+7
source

I also ran into this problem, and it seems to be a known bug:

https://developers.facebook.com/bugs/539702426044893?browse=search_507daefc9af416244781488

I haven't solved the problem yet, but for me it just looks like a simulator. My app seems to always connect via safari when installed on the device

Edit: So, after a bit more digging, I stumbled upon this thread: Login to FBConnect, share webview?

I realized that the dialog that we see is a uiWebView, which is actually a backup if the application cannot open the dialog in safari. I was able to get around my problem by restarting my simulator, which essentially clears the cookies. From your screen, I believe that you also work in the simulator. I wonder if you reset the simulator, if you had the same results?

From iOS Simulator menu → reset Content and Settings ...

0
source

Source: https://habr.com/ru/post/927151/


All Articles