Unable to like using Facebook iOS SDK
Asked Answered
S

1

0

I am trying to implement like in my Objective C application. If I am not logged into Facebook, then after tapping Like button, application opens login screen. I will log into my account. Then screen goes light gray with gray logo of Facebook for a while (with 2 shortly showed grey facebook screens before that) and then I am redirected back into my app. If I am logged into Facebook when running application, everything is the same except not showing login screen.

So my problem is, that I am not getting correct confirmation dialog that should appear after logging into FB account and I am redirected back into my app. Like is not placed.

What can be cause of this behaviour?

I have placed all 3 needed rows into .plist and this is how I am creating like button (p_webView is my subclass of UIWebView):

if (p_webView.fbLikeButton == nil) {
    p_webView.fbLikeButton = [[FBSDKLikeControl alloc] init];
}
p_webView.fbLikeButton.objectID = p_webView.article.url;
[p_webView.fbLikeButton setFrame:CGRectMake(p_webView.fbLikeButton.frame.origin.x, height + 5, p_webView.fbLikeButton.frame.size.width, p_webView.fbLikeButton.frame.size.height)];
[p_webView.fbLikeButton setCenter:CGPointMake(p_webView.frame.size.width / 2, p_webView.fbLikeButton.center.y)];
[p_webView.scrollView addSubview:p_webView.fbLikeButton];

More information - I have tried this on simulator (there I do not have FB app, so it was using Safari only). After loggin in, I have got error:

"The page you requested cannot be displayed at the moment. It may be temporarily unavailable, the link you clicked on may be broken or expired, or you may not have permission to view this page."

As it might be difficult to find solution - one needs to be in FB app as administrator, developer or tester for like button to work when testing app that has not been approved by Apple for using native like button yet.

Stylite answered 12/8, 2015 at 9:3 Comment(2)
What (kind of) user are you testing this with? An Admin/developer user on your app? What is the object that you are trying to like? If your app is public, have you requested (and received) the "Native Like Button" permission? What is your app ID?Finkelstein
I have tried both test account and my personal account (which was wrong, as this account is not set as tester nor developer in app). I need to like page with an newspaper article. App is public, but currently published version is without FB like button, that shall be one of new features. If I am not wrong, that permissoon I can get only after I will test it as working, or am I wrong?Stylite
S
6

You are doing right. Maybe you are missing something:

  1. You have to create fb app id and add it to iOS app. So you can open fb app when tap on Like button.(I think you did this)

  2. You have to add your fb acc (using to login) to dev/test roles in your fb app. If not you will be pushed back to iOS app after login to fb (in fb app or safari). <--- I think your problem is here. Ref: https://developers.facebook.com/docs/apps/test-users

  3. If you want everyone can login and like, you have to Submit Your App for Review (with Native Like button). After that, everyone can use Like button.

For the fb app setting, in the "Status & Review" tab, turn on "Do you want to make this app and all its live features available to the general public?"

After that you can see this "This app is public and available to all users" in Dashboard tab, instead of "This app is in development mode and can only be used by app admins, developers and testers"

Stipend answered 17/8, 2015 at 7:26 Comment(12)
Thank you, this looks correct. I will need to contact customer to get test user. If it will work, I will accept your answer and give you bounty.Stylite
I got the same problem (same behavior) as you got, and I fixed it with my answer.Stipend
I already have test account. Problem is, that this behaviour continues without any change. Where else can be the problem?Stylite
Did you get the test account for this app, with correct fb app id?Stipend
Here is my code. It works fine. _likeControl = [[FBSDKLikeControl alloc] init]; _likeControl.objectID = FAN_PAGE_FB; _likeControl.frame = CGRectMake(200, 911, 50, 50); _likeControl.likeControlStyle = FBSDKLikeControlStyleBoxCount; _likeControl.objectType = FBSDKLikeObjectTypePage;Stipend
And did you verify p_webView.article.url. Is it existing?Stipend
Edited my answer. Maybe you didn't set up your fb app properly.Stipend
FB app is managed by customer, which is quite unhappy for me, as I cant check it personally. URL is existing, so there would not be a problem. I have found that I can view error in delegate method openURL with error description: "the like dialog is only available to developers and testers" and error reason: "dialog disabled". I am testing it using test account that has been set up for this app and not using my personal account according to link in point 2 of answer. Should not my personal account be added to testers or developers and should not I use this real account for testing?Stylite
Did you read my edited answer? For the fb app setting, in the "Status & Review" tab, turn on "Do you want to make this app and all its live features available to the general public?" After that you can see this "This app is public and available to all users" in Dashboard tab, instead of "This app is in development mode and can only be used by app admins, developers and tester".Stipend
You can use any fb acc. "the like dialog is only available to developers and testers." Maybe, testing account didn't set up properly. Something is wrong. Can you add customer add your fb acc (or any account) to dev roles of this app?. So you can get a request and confirm. And can see more informations.Stipend
It's hard if we don't know the setting in FB app information. If we can config everything. We can create a example for like FB in 5 minutes, include: setting fb app, ios app and code. It's so simple.Stipend
How about this solution. You create an FB app your own. And implement like FB button. After it works fine, ask your customer to set up thier FB app.Stipend

© 2022 - 2024 — McMap. All rights reserved.