android facebook sdk publish feed to user's timeline - android

In my app I need to post certain content on user's timeline. I followed official tutorial given on https://developers.facebook.com/docs/howtos/androidsdk/3.0/publish-to-feed/. But in this tutorial, they've mentioned to set up Login flow first. And they have given a nice guide to do that. That's fine.
But the way I want is, user will be presented with Share Story button only. If user is logged in, story should be posted directly. And if not, normal login flow should be followed asking desired permissions and on login callback story should be published. I don't want to display Login button explicitly.
I stuck on this because in docs, everywhere they've mentioned to use <com.facebook.widget.LoginButton .... /> for login purpose. I don't want to use this at all as this will require user to interact two times. First tapping on Login button and second time to publish story he/she has to tap on Share Story button.
I can't find a way to check if user is not logged in and force him/her to login first from my code block.

It might be a bit late, but this appears to answer your question:
Android - Facebook SDK 3 - How to login programmatically without LoginButton

Related

Can a 3rd party app generate a facebook like in the background ( assuming the user is logged on via FB and agrees to like the page of course )?

The app can redirect you to the FB page in question and get you to press the like button. Trying to understand if that can be done quicker. Tks
No, that is not possible.
Facebook allowed liking certain object types in the name of the user via API until a while ago - but it has been removed since, simply because the feature was abused too much.
And Facebook pages could never be liked via API, that has always been possible via the official Like buttons only.

How to share image from my app on Facebook

I want to allow users to share image from my app on Facebook. Say I already have an image (i.e. file path). How do I go about letting a user share it on Facebook? Basically I want the user to agree once. Then from there on, whenever the user takes a certain action in my app, share a particular image on Facebook on behave of the user. Notice that the image is to be shared automatically without the user having to take action each time; so the Facebook sharing is incidental to some other action in my app. I am looking at the Facebook documentations. It is not clear which path to take to accomplish what I need. So thanks for any guidance.
Again, the user agrees once and goes on her merry way. Then the app, each time a user takes a certain action, share an image on Facebook.
UPDATE
Here is the path I have identified for sharing a photo on behalf of a user
Setting up your app to use Open Graph
Creating an Open Graph Story
Posting with API calls
The problem with this approach is that, at least in the sample project, the user has to click on Share each time. But I don't want the user to have to click on share each time. I want them to give me permission once. And then from there the app shares for them automatically.
Trial and error is expensive here as it is a lot to implement just to see if it were what I was looking to do: Which is why I am asking here, hoping someone here has done this in the past and don't mind sharing their experience.
You should ask the user for the publish_actions permission, and then use Request.newUploadPhotoRequest to publish a photo. https://developers.facebook.com/docs/reference/android/current/class/Request/#newUploadPhotoRequest
You need uses-permission Facebook, try this; https://developers.facebook.com/docs/android/getting-started
After you do this, you need to take method onClick and send the picture directly for facebook, but for this, is necessary the login of user's.

How to handle Facebook/Google login in android app having lot of activities?

I am new to authenticating through social networks on android so pardon me. I created activity with which i can login through facebook and google. I am planning to do this : user comes first time, ask him to login through Google or Facebook, once he does, let him go to other activities. How do i handle scenario when user closed and restart my app. I want my app to work both offline and online.
Method 1 : I am planning to store a bit in my sqlite DB which notes that whether user signed in through any social network, if he done then go ahead. Don't open login page multiple times and directly give user access to other pages. Problem with this approach is that if i want user to publish on his wall then i need to get him log in again before publishing (if session token expires). Rest seems fine. Also i will provide him a sign out button with which i will clear this bit for next time login.
What do you guys think about this approach? How other people does this in their apps with multiple activities. Assuming this approach works fine if we don't need to access facebook/google again and just need to get basic user data to let him login. Drawback, even he remove my app from his facebook/google account, i give him full access until he logout.
Method 2: Always on app start i check if facebook has session.isOpen() or myGoogleClient.isConnected(). If any of this gives true, i let user go in my app. Make sure with what network user logged in and show him log out button of that network. This check will only come when user restart his app. Once user login, does he always logged in or he see lot of login pages? I feel this approach is better.
Do i need to check for session open condition on each activity when transactioning through activities?
Any suggestions what approach is used by different apps. I want my app to be accessed for data in offline mode, but still let user access online feature when he is online.
Even when he is logged in with google, i want him to publish on his wall with facebook login, so will ask him to do so if he clicks on publish button, this way at times i have both logins and will chose any on them.
Please show me directions. I tried to find this on net and reached to above conclusions, but not able to finalize on right approach.

Facebook share button without using UiLifecycleHelper

I want to implement a share button in each of my activities. The idea is that when you press the share button:
if you are logged on it shares some hard coded strings (It is just a test, later i won't use hard coded strings)
if you're not logged, it send you to the facebook app login screen and after logged, it shares
I was following the Facebook tutorials, but they all use UiLifecycleHelper in which the user should press a Log In button before doing any other action. That is exactly what I do NOT want to do, because of the way the flow works on my app. I only need to post 1 single thing, not to maintain a session alive.
How can I do this?
PD: The reason I want to do it this way is because my app is NOT a social app. It is just a simple app that happens to have a Facebook share button, so you publish into your timeline some text. That's why I don't need maintain a session with UiLifecycleHelper

Facebook Like Button that Login with Facebook SDK for Android

I embedded the like button as a WebView in my Android app.
I have logged-in to my Android app using the facebook-android-sdk via SSO; but when I clicked the like button, it still prompted the login page (of course it did).
I want to know if there's any way to let the WebView know that I've already logged-in (for example provide the access_token somewhere in the webpage)?
Thanks.
See my answer to this question. In brief, you can't; but if you get the user to authenticate in the WebView once, you might be able to get the facebook auth cookie out of it and re-insert it into subsequent WebView instances.

Categories

Resources