Integrating facebook to android app - android

I have a simple question here. What is the need for integrating FB sdk to android app.
I can open the facebook url in web view and login and do whatever to be done on FB. Then what will be the scenario where FB need to be integrated with my app .

With Facebook sdk, you can upload photos directly to your Facebook albums, and also you can get all the user likes, friends and many more.
Compared to work with webview, the use of sdk saves time for your app user - he don't need to login every time he want's to enter his profile (Using sso - Single Sign On) or any other thing, that requires Facebook.
In my case, I activate the native Facebook app directly from my app, with my app page. In my opinion, if you don't need something more sophisticated, just showing page, you can use it.
In case there is no native Facebook app, activate it with the user browser (catch block).
try{
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/" + PROFILE_FACEBOOK_APP_ID));
startActivity(intent);
}catch(Exception e){
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.facebook.com/UserNamePage")));
}

In general, the integration is used when the developer wants to post on a users' behalf, add pictures directly to specified albums, get a user's email address etc.
These can be done when the user authorises the app for the first time, they also authorise the privileges.
It is also seen as a marketing tool, as all the posts will say via (yourAppName), so you can gain some online presence.
Like Ofir A said, it is time saving for the user as they only need to log in once.

Hi Why you are calling webview with facebook link.You should use FaceBook Native Sdk for Android.This giveing your better user experience compare to webview. Refrence for Facebook Integration

Related

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!!

Native Facebook Login experience via browser

I have seen several flavours of this question going around but nothing exactly specific nor answered so trying it myself.
I am trying to build a Facebook login experience via the browser into my Facebook-based app that will require the users to not remember their passwords as much as possible. This means that if
they log in via their desktop browser and are already logged in, it will only ask them to 'OK' the permissions
they log in from their mobile browser and are logged in via their respective native app (Android/iOS), it will simply redirect them to the native app, ask for the app permissions and redirect them back to the success page on the browser
they log in from any browser and are not currently logged onto Facebook in any form, they have to enter their password and authenticate (whether natively or via browser this does not matter)
I know how the first can be done - that is pretty straightforward using the JS SDK. The second point is the tougher bit.
I am aware of existing custom URL schemes for Android and iOS but nothing specifically really mentions how that can be used for authentication and/or authorisation of Facebook apps. Does anyone have any ideas on how this can be done?
Thanks!
In iOS use iOS facebook SDK. It will handle the login process effectively in different situations depending on the resources available. Check out this answer to know about different login flows
Integrating facebook
You're looking for Single Sign On behavior- in Facebook, use the native SDK, and instructions for setting up SSO. It includes entering your bundle id in the settings and setting up a referring url name (the name of your app usually). So what happens is- if you launch safari mobile, and log into facebook. Then, launch your app, with good integrated SSO. Then, it won't require you to login/pass, because it knows you've authenticated via browser. Same with Android.
I think what you are looking for (at least for Android) is starting an Intent on certain schema that will open Facebook app.
This is answered here Android facebook intent to show profile with class com.facebook.katana.ProfileTabHostActivity doesn't work any more

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.

How to get facebook authentication from Android login form

Is it possible to login into facebook using my own login form in Android & get the facebook user id? I just want to validate the users without need them access their facebook.
In the Android facebook tutorial, the app have to open facebook first so that user can login but there is no automatic close after user login successfully.
Thanks in advance
No, you don't have a way to log the user in through facebook without using their official endpoints.
You can open some sort of browser with the authentication dialog (or the open graph one) but that still mean using their forms/ui (what ever you want to call it).
You should just use the android sdk without using the SSO, that way the sdk won't call the facebook application that is installed on the device (if at all) and will just call the auth dialog for you.
This is a better solution for you since it "abstracts" some things from you, takes care of the access token and more.
Here's a thread about disabling the SSO: How to disable Facebook single sign on for android - Facebook-android-sdk

Integrating Facebook and Twitter feeds in Android application

I'm adding social integration to my app, and am looking for general advice how to go about it.
At the moment the app is showing feed of particular Facebook wall (authentication handled by Facebook's Android SDK) and feed for particular Twitter hashtag. That's a start, but I want these feeds to do a bit more. For Facebook:
For long feed items, user should be able to "see more", including linked pictures
Links inside feed items should work and open in browser
Like/unlike feed items
Comment on feed items
Post on the wall (create another item in feed)
Similarly, for Twitter:
Links inside tweets should work and open in browser
Reply to, and retweet tweets
Create tweets that contain the specific hashtag
Since Facebook and Twitter both have comprehensive APIs and there are enough code samples floating around, this is all technically doable, but seems a lot like reimplementing Facebook and Twitter clients. That's a lot of work to get all the little details right, maintain code for API changes,
and not really in the scope of my app.
So I'm thinking how to avoid reimplementing Facebook and Twitter clients.
Idea one: direct user to mobile versions of the respective sites and be done with it. Downside is that user will have to go through cumbersome authentication, even if there are dedicated client apps already installed and authenticated on user's device.
Idea two: plug into existing apps using intents system: if official Twitter app is installed, use that to do hashtag search. If Seesmic or Twidroid or some other twitter client is installed, use that. As a fallback, open Twitter's mobile website in browser. Similar for Facebook. Downside here is that intents for "show facebook stream" or "search tweets for X" are not standartized. Most current apps don't even have documented ways to plug into them. Using undocumented entry points in those apps is possible but would make my app hacky and brittle.
So, this question, how you've been dealing with integrating bits of Facebook and Twitter functionality in your apps, or seen done by others?
Here is a good tip about how to implement twitter/facebook oauth:
Create new activity and name it OAuthActivity.
Create new class that extends WebView.
Follow the facebook developer guide for WEB applications (not mobile ones!) and implement oauth calls inside of your WebView. For Twitter use Signpost-core with signpost-commonshttp4 to get oauth (facebook uses its own variation of oauth so you need to do it yourself).
Override WebView so it closes itself when facebook redirects your WebView subclass to your callback url.
Use OAuthActivity to return OAuth key / secret to your main activity via RunActivityForResult.
This way screen orientation change will work; you will have same architecture for FB and TW.
I have implemented it this way, yet I can not share my code (it is licensed for my company).
When I added Facebook and Twitter integration into my app (shameless plug: Secret Message), I attempted to invoke an installed Twitter client app via Intent. It wasn't fun, because there is no such thing as a "facebook/text" or "twitter/text" Intent. I know some Twitter apps create their own, but they're not universally used or even known.
So the other option is to get a list of all installed apps and filter on those you want to display in a chooser for the user to select. But retrieving a list of packages and their user-friendly names takes forever. So I hated that option.
I ended up integrating a very simple GUI for both Facebook and Twitter into my own app, and just used OAuth to authenticate users.
I hope this helps you pick your direction.
implementing Twitter integration is pretty easy on Android (you can use Twitter4J which is a pretty nice Twitter Java Library to access the public web services).
To integrate tweeting/retwreeting is basic stuff once you have authenticated your twitter user (just have a text box to allow users to enter thei 140 characters and a button to submit it - creating tweets, retweeting, replying etc is all a matter of 1 or 2 lines of code using twitter4J). The link stuff requires formating your listview to handle weblinks and open as appropriate.
The toughest part of the whole twitter integration thing is getting the OAuth stuff done - there is a tutorial on how to implement twitter and the OAuth authentication stuff here
Unfortunately, I have never tried facebook integration, but hopefully someone will be able to help out with that.

Categories

Resources