Using the Facebook SDKs WebView to show custom web page? - android

I'm wondering if it's possible to use Facebooks Android SDK to open up a Facebook WebView but instead of showing facebook related stuff I wanna show my custom page which is using Facebook Comments Social Plugin.
The reason? I wanna make use of the cookies that are stored in that WebView so that a user doesn't need to login again if he's already been logged in. And in the case that he's not logged in, he can login using the SDKs Login Flow.
Is any of this possible?
Thank you!

Related

Facebook - Show facebook user Feed in webview like browser

Thank you in advance to see my Question.
I have task of facebook in my android application. I have to integrate Facebook SDK for Authentication by facebook. When I use facebook api to get the feed of user that time i got the #JSON response from the server side.
So I made the custom layout to show that user's feed.
But I need to show load the user feed in my webview in Android.
So Facebook provide any #Url for the user feed to load that Url webview? so we show facebook feed like #browser.
Officially it is not possible to pass the Facebook SDK Token to a WebView. As far as I know it is currently not possible to do it.
One workaround I used in one of my apps (to display a like button before it was part of the SDK) is to set the Login Dialog to web only. By doing this the Facebook SDK creates a LoginDialog using a WebView whereby it has an active Facebook session after login.
This can be done by setting the LoginBehaviour of either the LoginManager or the LoginButton:
login.setLoginBehavior(LoginBehaviour.WEB_ONLY);
Please be aware that this is only a workaround and could stop working in the future.
Just open m.facebook.com directly, this way it will take you to user's wall after login. and As its already logged in by authentication, session will remain active.

Facebook android SDK login action

I'm new to Facebook SDK.
So as far as I read from their tutorial, when you use custom button with their loginManager, it starts an intent of webview or the native FB app to ensure the login.
So my question, is there a way to make it custom ? like using edittext of android to get the username/password then start the login session.
Thanks.
Regards.
You can not do that for security reasons. With the facebook sdk, your app open a webview or the facebook app if the user already has installed.
If you want to save some user data, you have to set the proper permissions and you can get it with the user token and the facebook graph api.
Regards!!

Use access token to create a facebook cookie?

I have an app which uses the Facebook SDK for various stuff (sharing, like etc).
My problem is that; inside my app, I also show an WebView which exposes a webpage with Facebook Comments (Social Plugin). My problem is that, a user which login to facebook using the Facebook SDK also has to login to facebook inside the WebView.
So my question is: Is there any way to use an access-token (or any other way) to create a facebook session cookie that I can set so that the user is also logged in to facebook inside the WebView?
No, you cannot use an access token to create an FB cookie. This is by design and is for user security.

How to login into facebook in WebView if already have access token from FB SDK in Android

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 :)
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 :)
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.
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.
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
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

Android: Avoiding two logins to Facebook (SDK and Browser) while integrating a page "like" button

I am trying to add a LIKE button to my android app that the user can press to like a fan page.
To my understanding, this is not possible because of Facebook security restrictions.
My alternative is to display a Like button using WebView with the "like social html code" provided by Facebook.
The issue with that approach is that the user will have to re-login to Facebook using the web interface for him to see the like button. That is, after he already logged in using the SDK authentication (which is also a web view).
Is it possible to do all of that using only one login?
How is it that logging in using the SDK does not save the cookies to the default web browser (the SDK uses a web view...) ?
Are there any alternatives to accomplish that?
Try logging into your application with SSO. Non SSO(Normal) authentication uses the Facebook application installed on the app. If you do a SSO FB login into your app and simply pass a url to webView for the "Like" feature, I guess it should work because you are using a SSO FB login for the app and pre installed facebook app on the device to handle the webview's FB.
I am hopeful about this. Please share your feedback.

Categories

Resources