How can I customize Facebook SDK 3.0 for Android? - android

recently I have been working on Facebook SDK 3.0 for Android.
While everything was done smoothly, I found the following issue.
When the user presses a facebook Login button on a device where native Facebook app is not installed, a webview login activity appears. After logging in, the login page appears again even when the app requests user's permissions. (This is a known issue according to Facebook http://developers.facebook.com/bugs/333926600053215)
So, until Facebook fixes this issue, what I want to do is to detect whether the user has FB app installed on his device, and if not I want to show my customized webview that handles login process.
Since I have all the source codes in Facebook library project, I think I can customize that but the question is, how should this be done?
If I make a change on one of those files in the library projects, will it be automatically applied to the main project that uses this library project? What would be an efficient way to customize the facebook library project?

I faced the same issue and partially solved it: roughly, i attempt to obtain login with publish permissions, if it's rejected then the fb application's installed and then i request read-only then publish, if it's not rejected then you get the login with publish permissions coming up right after it and you're good to go.
problems with this solution:
1) 3 user interactions instead if 2 if the fb app's installed.
2) bug if cancelling the login with a webview (a second one appears), though i think this one's solveable, i didn't have time to try.
sorry for quick/curt reply.

Related

Android Facebook Share Dialog Blocks Login Due To Embedded Browser

I am using the cordova-plugin-facebook-connect plugin to launch the share dialogs from Facebook. iOS is working great, and Android is working great when the app is installed.
On Android, if the app is not installed, it tries to share with an embedded web browser. After entering my email and password, I get an error saying that logging into Facebook from an embedded browser is disabled. I am using the latest version of the plugin, which SHOULD mean the latest Facebook Android SDK
I have looked on our business dashboard and made sure that embedded login is allowed:
...but that mentions OAuth so maybe it's not relevant. I have uploaded the debug and production key hashes to the dashboard
I have found nothing on the Facebook docs and I haven't gotten an answer from the Facebook developer community.
To sum up:
If the app is installed, it is all good. Without the app, it uses the embedded browser, but Facebook is blocking the login. I would love to know WHY and how to enable it.
UPDATE: Using a Facebook generated test user worked
Cheers
As Recommended by Facebook please update Dependencies to
implementation 'com.facebook.android:facebook-android-sdk:[8,9)'
Ref :
https://developers.facebook.com/docs/android/componentsdks/
https://developers.facebook.com/blog/post/2021/06/28/deprecating-support-fb-login-authentication-android-embedded-browsers/
Facebook has let everyone know that they are deprecating support for FB Login on Android embedded browsers:
https://developers.facebook.com/blog/post/2021/06/28/deprecating-support-fb-login-authentication-android-embedded-browsers/
As of right now, they are blocking High Risk users with this error and will block everyone starting in August. Their suggestion is to use a later version of the SDK (8.2+) to avoid this
I can't comment (yet) so I'm creating this answer to ask you if you could try and remove all (!) local browser data, i.e. Cookies and local storage, etc. This is the first thing that came to my mind when I read "works with another login".
The issue is resolved if the user has enabled 2-factor authentication via facebook.
I have tested this with multiple real users now and for example enabling sms-2fa does enable the user to login into apps with an embedded browser. The login happens as usual if the user has the facebook app installed on the same device and already logged in on the facebook app with 2fa. Otherwise, facebook will request the 2fa when logging in but a login is possible again.
I have however found out that some apps seem to crash if they had been opened before 2fa had been activated on a phone with a facebook app and those apps need to restarted before trying to login on them again.
From this we can assume facebook blocks out embedded browsers due to their risk assessment. 2fa is specifically presented as an option to login via unsafe browsers within the security options of each user individually and sadly does not seem to be an issue on the side of who ever is using an embedded browser within their app.
This also happened to me but I've fixed it.
I just uninstalled my Facebook application and used my browser instead.
Try installing another browser, like Firefox, and set this the default browser, then login again with your Facebook credentials. It worked to me. I guess the problem is with chrome. For me, it worked when I set Firefox my default browser.
For your account security, logging in to Facebook from an embedded browser is disabled. You may be able to continue by updating the app you're logging in from and trying again.

Can't test my own app using Facebook with android sdk

I'm working on learning about the Facebook sdk with Android and I wanted to test posting on my own wall, and I read on my app's dashboard page that administrators can test apps fully. My app still doesn't post to my wall though and I feel that it is because it hasn't gone through the approval process (which makes no sense to me because I'm an admin for it).
What gives?
i have already used facebook sdk and i used the request class to do this after login. The solution is here https://developers.facebook.com/docs/reference/android/current/class/Request/

Android Facebook SDK SSO "the page you requested cannot be displayed"

I've been stuck on this very frustrating problem all day and through Google I've found many people with the same problem with no answers that relate to the new Facebook API for Android. I have followed the steps listed here exactly :
https://developers.facebook.com/docs/getting-started/facebook-sdk-for-android/3.0/
When I run the sample app on my device I get this:
When I run it on the emulator it works. I understand this to be because of Facebook's SSO implementation. The emulator does not have facebook installed so it signs in for the first time successfully, but the device launches the facebook app and for some reason gives this error and when I travel back, it is as if I am not logged into facebook at all and there is no active session (though I am because when it launches the facebook app I can browse friends, etc.)
I cannot uninstall facebook on my device and even if I could that would be unacceptable for the app users. If possible, I'd like to retain the SSO feature, but somehow make it work!
I have spent all day going back and forth with my Hash Keys, and generated them through my device+code and with the keytool and they match so the problem is not related to that. Besides, the sample app runs on the emulator which surely means its an SSO problem. Thanks in advance.
After 8 hours of scanning through my code and the facebook docs, I simply decided to update my facebook app on my tablet ( I never use it and so never bothered to update it ) and now it all works.
I guess the Facebook app on my tablet was pre-SSO of Facebook on Android, but my created app was expecting it to be supported and giving the error.
Just to be a bit more clear, if you are either running on your device or on the simulator, make sure you have the latest Facebook APK installed. Facebook changed their permissions a while ago, and you may have to manually go to the Google Play store in order to download the updated version of Facebook (it may not auto-update for you given the permission changes).
Disabling Facebook did the trick for me. It forces the app to launch the browser and surf to Facebook that way

Authorization hangs on App authorization page

In Hackbook Android sample and any other Facebook SDK 3.0.1 samples i getting trouble to login.
I go through facebook login dialog and after successful authentication then app authorization dialog appears: "Hackbook would like to access your public profile, friend list and photos" with Cancel and OK buttons. Click on any these buttons has no effect. Only way to return to app is press hardware back button.
Samples works well some days ago. I've tried to register own app id and replace it in samples, generate hashes for android native application, change app name and package, nothing helps.
Please point what's going wrong.
I experienced a similar issue which might be afflicting you as well. I had the same behavior you are seeing and I figured out it was due to having the "Don't keep activities" developer option turned on. If that option is on and you have not yet logged into the native Facebook app then you will go into an infinite loop on login. It is a bug with the Facebook SDK for Android.
Here is the bug report, https://developers.facebook.com/bugs/269489836511974.

More advanced android facebook example

I'm having some problems with facebook integration on my android app. I've looked at the examples that come with the api and i can do the things shown in those ok. But i'm having problems with other things such as getting single sign on to work properly, authentication across multiple activities in the app and loading a facebook page (non-api call) without being asked to log in again.
Anyone have examples that show these?
When making API calls, you usually need to include the access_token parameter that was issued when the user authenticated. This is how facebook knows who you are when you make requests.
Similarly, when loading facebook pages (not using the API), you have to remember to send the cookies Facebook sent when the user logged in. Normally the browser keeps track of these automatically, but in your program or app you might have to handle them manually.
I don't have experience with Android specifically, and I don't know what you're using to load and render facebook pages, but knowing how facebook is keeping track of logged-in users should give you an idea of where to start. A google search or two should get you on your way.
Go to facebook.java class and change package name com.facebook.katana to com.facebook.katanaaa or any one of your own choice. This worked for me .

Categories

Resources