4

I have Facebook SDK integrated in my android app, with login button, which is working perfectly and everything else is fine. I need to add webview to make like button, but it says I'm logged out and Facebook SDK session doesn't make any difference. I mean, if I log in using Facebook SDK, webview still shows I'm logged out. So, how can I pass Facebook SDK session to webview session?

Gintas_
  • 4,940
  • 12
  • 44
  • 87

2 Answers2

2

There is no such way to share your android hosted access token from session with webview context, you can look that duplicated question about it. Share session facebook SDK with webview

Community
  • 1
  • 1
Jans
  • 11,064
  • 3
  • 37
  • 45
  • not sure of that, in buzzfeed app if you are logged with facebook in the app, the facebook comments plugin they use embedded in a webview has the user session – Jorge Arimany May 28 '15 at 22:56
1
  1. Login with LoginBehavior.SURPRESS_SSO, which uses a web dialog for Facebook login. After this, WebView has an active Facebook session. I've tried with Facebook SDK v4.1.0.

    loginButton.setLoginBehavior(LoginBehavior.SUPPRESS_SSO);

    or

    loginManager.setLoginBehavior(LoginBehavior.SUPPRESS_SSO);

  2. As others mentioned, pass token to WebView through JavaScript interface or URL query.

  3. Did you use WebView just for like-button? It is available for Android since 3.19.0. https://developers.facebook.com/docs/sharing/android#buttons