23

I'm developing android app in which I have login via Facebook SDK. In app I also have facebook social comments displayed in webview. But problem is even if user is logged through fb sdk, the webview doesn't know about it and for posting new comment it requires user to login.

My question is: Is there any way how to pass login from facebook sdk session to webview? For example by some javascript function to which I give access token string and call it on webview so it gets logged in and ready for posting comments?

Thanks :)

bakua
  • 13,704
  • 7
  • 43
  • 62

5 Answers5

1

So with what I figured out to this point, there is no way how to pass loged session to WebView.

Here is my solution to this problem: At your remote server make webpage with login interface using Facebook JavaScript SDK and then display it in WebView. This way all WebViews in your app will share same login cookie and everything will work as you want.

Or you can load m.facebook.com directly, but this way it will take you to user's wall after login. Above solution offers you to display another content after login as users picture and info only (with log out button of course).

Hope it helps :)

bakua
  • 13,704
  • 7
  • 43
  • 62
1

If some user still want to use facebook login page, you can try to use the android Javascript Interface to pass the access_token to the Android Facebook SDK.

Hugo Gresse
  • 17,195
  • 9
  • 77
  • 119
0

You can try to pass the access_token from the native sdk to the webview via query string.

myWebView.loadUrl('http://mydomain.com/?access_token=' + facebookAccessToken);

And in your webview check if the access_token is set and use it with the javascript sdk, hope it helps someone with the same issue.

norman784
  • 2,201
  • 3
  • 24
  • 31
0

Facebook Rest API service is already deprecated.
You can user Facebook SDK to login and access details from facebook. Check the facebook documentation.

https://developers.facebook.com/docs/android/login-with-facebook/v2.2

rasfarrf5
  • 219
  • 1
  • 5
-4

Did you try out the tutorials in developers.facebook.com/, here they clearly given how to login. Once you logged in the details of the user will be cached, if you need to publish any data you might need permission for that, so you will be directed to login activity once more. Its given in this link

Linson
  • 655
  • 1
  • 7
  • 21
  • Yeah, thanks for response :) but those tutorials are about different thing than one that I'm askink. Anyway I figure it out my way – bakua Mar 29 '13 at 17:57
  • Hi, if I remember correctly I just created facebook login webpage and used this one instead of facebook SDK. But that was a long time ago and propably not correct solution. What do you need it for? – bakua Nov 04 '14 at 08:35