Infinum Android Talks #13 - Developing Android Apps Like Navy Seals by Ivan Kušt
Infinum Android Talks #14 - Facebook for Android API
Transcript of Infinum Android Talks #14 - Facebook for Android API
![Page 1: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/1.jpg)
We design and develop great software for mobile and web.
![Page 2: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/2.jpg)
Facebook for Android API
Android talks #6 Željko Plesac
![Page 3: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/3.jpg)
Scope• Introduction
• Prerequisites
• Common Facebook API actions
• Graph API, custom stories, Facebook Insights
• Conclusion
![Page 4: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/4.jpg)
1. Introduction
• Facebook is the world’s largest social network, with more than 1 000 000 000 users
![Page 5: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/5.jpg)
1. Introduction
• Facebook is the world’s largest social network, with more than 1 000 000 000 users
Facebook is the world’s largest repository of personal information!
![Page 6: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/6.jpg)
Why use Facebook?• obtain information about users
• use it as authentication system
• export information from our applications to Facebook
• attract new users
![Page 7: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/7.jpg)
Why use Facebook?• obtain information about users
• use it as authentication system
• export information from our applications to Facebook
• attract new users
Everybody and everything !is on Facebook!
![Page 8: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/8.jpg)
Prerequisites
• Facebook account
• Facebook for Android SDK - current version is 3.15.0 (officially not on Maven)
• applications have to be registered on Facebook (http://developers.facebook.com) and we need to provide some basic info
![Page 9: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/9.jpg)
Common Facebook actions
• 1. Facebook login
• 2. Post to wall
• 3. Read user data
![Page 10: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/10.jpg)
Facebook Login
• Applications must implement Facebook Login
• OAuth 2.0.
• session management
• obtain default permissions
![Page 11: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/11.jpg)
Permissions???
![Page 12: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/12.jpg)
Permissions• due to the personal nature of user informations,
Facebook has developed complex schema for accessing personal data
• informations are categorised; in order to access them, you need to obtain permissions from their owners (users)
• permissions can be requested at any time
• by default, with login you obtain 3 permissions: email, public_profile, user_friends
![Page 13: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/13.jpg)
![Page 14: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/14.jpg)
Post to wall
• we want to export informations from our application to users Facebook wall (write comment, upload pictures, share links…)
![Page 15: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/15.jpg)
This should be easy…
![Page 16: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/16.jpg)
Post to wall
• 3 cases
• with Facebook native application
• with WebDialog
• with background request by using Graph API
![Page 17: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/17.jpg)
Post to wall - case 1.• only possible if user has installed Facebook for
Android application
• check:
![Page 18: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/18.jpg)
Post to wall - case 1.
• 2 dialogs: ShareDialog and PhotoShareDialog
• no additional permissions are needed
• user has to manually confirm publish action
![Page 19: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/19.jpg)
Post to wall - case 2.
• If Facebook for Android application is not present on mobile device, we can use WebDialog
• no additional permissions are needed
• user has to manually confirm publish action
![Page 20: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/20.jpg)
Post to wall - case 3.
• Applications can post automatically to users wall by using Graph API requests (not visible to user)
• in order to use this feature, app has to be submitted for Facebook review
![Page 21: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/21.jpg)
Facebook review???
![Page 22: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/22.jpg)
Facebook review• In order to use advanced features of Facebook, like
background write to wall, custom stories, etc… applications have to be submitted for Facebook review
• Applications have to comply with Facebook Terms
• All platforms are submitted to review
• Every feature has to be reviewed
![Page 23: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/23.jpg)
• Upload photos - users must take these photos with an actual camera. All photos must be original
• Tags - all tags must be manually added by user
• User messages - users must personally write these messages. Even if users can control (edit or delete) the message content, applications cannot pre-fill user messages
• Applications must use the latest versions of SDK
• Applications must implement Facebook login
Example of terms
![Page 24: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/24.jpg)
Review survival cheat sheet• all banners, icons and screenshots have to be in exact dimensions
• banners need to contain app name
• check for grammar errors
• provide real app data
• remove all unnecessary restrictions from your app
• don’t cheat - Facebook could disable your account and blacklist your application
![Page 25: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/25.jpg)
Graph API• primary way for apps to read and write to the Facebook social graph
• social graph a representation of the information on Facebook composed of:
• nodes (basically "things" such as a User, a Photo, a Page, a Comment)
• edges (the connections between those "things", such as a Page's Photos, or a Photo's Comments)
• fields (info about those "things", such as the birthday of a User, or the name of a Page).
• HTTP based
• be sure to ask users for permissions!
![Page 26: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/26.jpg)
OpenGraph stories• People use stories
to share the things they're doing, the people they're doing them with and the places where they happen.
![Page 27: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/27.jpg)
Graph stories• Every story has 4 elements:
• Actor - person who published the story(i.e. Brie Taylor)
• App - app that publishes the story on the actor’s behalf (i.e. “Goodreads”)
• Action - activity the actor performs (i.e. “finished reading”)
• object - object the actor interacts with (i.e. book “Ask the Dusk”)
![Page 28: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/28.jpg)
Common actions• Set of predefined actions, i.e.
• read a book
• listen to music
• watched the video
• they don’t need to be created, you can just start publishing them
• more at https://developers.facebook.com/docs/reference/opengraph/
![Page 29: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/29.jpg)
Custom stories
• Open graph stories created solely for our application
• have to comply with Facebook terms
• must be reviewed on test user before they can be used in production
![Page 30: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/30.jpg)
Custom stories
![Page 31: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/31.jpg)
Custom story code snippet
![Page 32: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/32.jpg)
Facebook Insights
• for collecting analytics
• data are collected anonymously
• can be shared with other Facebook users
![Page 33: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/33.jpg)
Facebook Insights - example
![Page 34: Infinum Android Talks #14 - Facebook for Android API](https://reader031.fdocuments.in/reader031/viewer/2022030307/58e8d29b1a28abb3398b5925/html5/thumbnails/34.jpg)
Conclusion
• Facebook can greatly increase user experience of your application
• it’s not something that will be implemented in 15 minutes
• integrate Facebook at the beginning of development process due to various reviews