Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Like Button integration (task #201437) #17

Closed
JohnWeidner opened this issue Jun 3, 2010 · 17 comments
Closed

Like Button integration (task #201437) #17

JohnWeidner opened this issue Jun 3, 2010 · 17 comments
Labels

Comments

@JohnWeidner
Copy link

I'd like to be able to have a WebView with a "Like Button" in it. This almost works. However, even if my app has the "offline_access" permission, the like button wants the user to re-login if they have logged into facebook somewhere else since they last logged into facebook via the app.

@soneff
Copy link

soneff commented Jun 4, 2010

Could you provide a bit more detail? How are you generating the content for the WebView, or what URL are you trying to load?

@JohnWeidner
Copy link
Author

I tried using the iframe code provided by the like button code generator at http://developers.facebook.com/docs/reference/plugins/like. But since an iframe is basically the same thing as a WebView, it seemed redundant to load the code in an iframe and then load the iframe in a WebView. So instead I just loaded the code that would be in the iframe directly into the WebView using the code below. But the same thing happens either way.

private initLikeButton( String urlToLike ) {
    likeWebView = (WebView) findViewById( R.id.likeWebView );
    likeWebView.getSettings().setJavaScriptEnabled(true);

    String url = "http://www.facebook.com/plugins/like.php?" +
           "href=" + URLEncoder.encode( urlToLike ) + "&" +
           "layout=standard&" +
           "show_faces=false&" +
           "width=375&" +
           "action=recommend&" +
           "colorscheme=light&" +
           "access_token=" + URLEncoder.encode( FacebookAdapter.getInstance().getAccessToken() );

    likeWebView.loadUrl( url );

}

Incidentally, the same issue exists when developing an iPhone app. We don't want the user to have to login to facebook every time they run our app. But unfortunately, if the user has logged into facebook on another computer since the last time they logged into facebook via our app, they'll have to log in again.

On the android platform I would think a better solution might be to have a facebook app that you send an intent to that takes care of keeping the user logged in and returning the html for rendering the like button.

@soneff
Copy link

soneff commented Jun 7, 2010

OK, I see, nice trick. Looks like the issue is that there are several types of Facebook cookies, and the one that the Android SDK uses in the WebKit webview is not the same as the one used to implement the "Like" button on the web, hence the need to log in again. I'll find someone who know more about the cookies and see if they can propose a solution.

@soneff
Copy link

soneff commented Jun 8, 2010

Correction: the Facebook Android SDK dialog (such as the login dialog) and the "Like" button currently use the same cookie: a c_user cookie. You are quite right: with a c_user cookie, there are a limited number of sessions that may be active (up to five where the user has checked the "Keep me logged in" button, but only one if they have not), so if the user logs in elsewhere, it may invalid the c_user cookie on the device, requiring the user to log in again when trying to display a like button inside a webView dialog.

Using intents or a similar technique, such as creating a "like" dialog type supported by the SDK, or using a different cookie that does not get invalidated or expire, are potential solutions: I'll ask the relevant people what can be done, but I'm not sure if there will be a quick fix....

@ayanir
Copy link

ayanir commented Jul 7, 2010

Hello,
is posible to use the Graph API to implement the "Like" methode same as the "me" etc.?
if it is possible then we can just use the relevant String action.

@EvgenyAndroid
Copy link

Hi John,

Have you managed to solve this problem? I'm currently using WebView and graph API with OAuth to get access_token etc.... however as you know Like is Open Graph protocol and yet not supported on Mobile....

Any idea how to implement it?

Cheers,
Evgeny

@bgold
Copy link
Contributor

bgold commented Jan 5, 2011

Using a WebView with a Like button in it is buggy and unsupported, and is broken if your app uses single sign-on. We're working on a better solution and will let you know when it's ready.

@olgatchoum
Copy link

Hi,
Is it possible to use the Like button as the social plugin does, from the Android SDK?
It would be just great to use it with an mFacebook.dialog(...)...
Cheers,
Olga

@mdpedersen
Copy link

Hi,

Brent, could you tell us if there is an ETA for a working Like feature? It would really be helpful.

Thanks,
Michael.

@eldolor
Copy link

eldolor commented Mar 16, 2011

I have a couple of Android apps that can leverage the Like button. If you want, I can help you test and enhance the functionality, even if it is in an early development stage.

Please let me know.

@EvgenyAndroid
Copy link

That would be great, can we connect on - info@ecoffeecard.com.au
*
*
*-Evgeny
*
On 17 March 2011 08:41, eldolor <
reply@reply.github.com>wrote:

I have a couple of Android apps that can leverage the Like button. If you
want, I can help you test and enhance the functionality, even if it is in an
early development stage.

Please let me know.

Reply to this email directly or view it on GitHub:
#17 (comment)

@aduran1700
Copy link

Have you guys made any progress on the like button integration?

@eldolor
Copy link

eldolor commented Apr 21, 2011

I have integrated the Facebook Like Button on my Android apps (Beer Cellar, Wine Cellar). I used a WebView to do so, as described by JohnWeidner. The only part that is tricky is managing the flow when a user is not logged in. I used the View.OnTouchListener to verify that fact, and to control the login process. It was relatively straightforward.

@ir2pid
Copy link

ir2pid commented Jul 11, 2011

@eldolor could you elaborate how the flow was controlled and how you verified if a user isnt logged?

@Born-in-Hell1988
Copy link

@bglod

Hello bgold,

when sso is implemented, Like button always authenticates the user to log in irrespective of whether we provide the access token or not. I am using the above code to implement the Like button.

Is this a bug? Is it documented ? Any workarounds?

This will be a terrible user experience if he has to Login to 'Like' each time.

Regards,

Sad Developer.

@manitringapps
Copy link

Any update on this? Still issue persists...

@jamesgpearce
Copy link

This issue was raised against an previous version of the Facebook SDK for Android.

In 2012, the SDK had a significant rewrite and relaunch, and we are closing issues and pull requests that predate that v3.0 release.

If you are still experiencing this issue, please raise a new issue with repro steps in the supported SDK (currently v3.6). For more information, please see our Android developer center at https://developers.facebook.com/docs/android.

Many thanks for using the Facebook Platform, and your support of this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests