Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Building Your First Social App - AnDevCon

Building Your First Social App - AnDevCon

Deck from AnDevCon Boston

beardouglas

May 29, 2013
Tweet

More Decks by beardouglas

Other Decks in Technology

Transcript

  1. developers
    Bear Douglas and Christine Abernathy
    github: beardouglas, caabernathy
    @beardigsit @caabernathy
    Building Your First Social App
    Wednesday, May 29, 13

    View Slide

  2. http://developers.facebook.com/android
    Wednesday, May 29, 13

    View Slide

  3. github.com/beardouglas/andevcon
    Wednesday, May 29, 13

    View Slide

  4. Login
    Wednesday, May 29, 13

    View Slide

  5. Facebook Login on Android
    Create a Facebook app
    Add the Facebook SDK to your project
    Add your Facebook App ID to your Android Manifest
    Add Facebook Login and start sharing
    Wednesday, May 29, 13

    View Slide

  6. The Facebook SDK for Android
    Native UI
    Graph
    Core
    LoginButton
    GraphUser
    FriendPickerFragment ProfilePictureView
    GraphObject.Factory OpenGraphAction
    Request UiLifecycleHelper Settings
    Session
    Wednesday, May 29, 13

    View Slide

  7. The Facebook SDK for Android
    Native UI
    Graph
    Core
    LoginButton
    GraphUser
    FriendPickerFragment ProfilePictureView
    GraphObject.Factory OpenGraphAction
    Request UiLifecycleHelper Settings
    Session
    Wednesday, May 29, 13

    View Slide

  8. Connecting to Facebook
    valid
    cache?
    new Session()
    session.openFor…()
    session.open()
    OPENED
    success?
    CLOSED_LOGIN_FAILED
    Yes
    Yes
    No
    No
    Wednesday, May 29, 13

    View Slide

  9. @Override
    public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    uiHelper = new UiLifecycleHelper(
    getActivity(),
    callback);
    uiHelper.onCreate(savedInstanceState);
    }
    Wednesday, May 29, 13

    View Slide

  10. Demo
    Follow along:
    github.com/beardouglas/andevcon
    Wednesday, May 29, 13

    View Slide

  11. What’s next?
    Wednesday, May 29, 13

    View Slide

  12. Wednesday, May 29, 13

    View Slide

  13. Wednesday, May 29, 13

    View Slide

  14. Like
    Wednesday, May 29, 13

    View Slide

  15. Like
    play
    Wednesday, May 29, 13

    View Slide

  16. Like
    play
    Like
    Wednesday, May 29, 13

    View Slide

  17. Like
    play
    listen
    Like
    Wednesday, May 29, 13

    View Slide

  18. Like
    play
    listen
    Like
    read
    Wednesday, May 29, 13

    View Slide

  19. Like
    play
    listen
    Like
    watch
    read
    Wednesday, May 29, 13

    View Slide

  20. Like
    play
    listen
    Like
    pin
    watch
    read
    Wednesday, May 29, 13

    View Slide

  21. Like
    play
    listen
    Like
    pin
    watch
    read
    check in
    Wednesday, May 29, 13

    View Slide

  22. The Graph API
    https://graph.facebook.com
    API for people, things, and the connections between them
    ▪ /me get profile information for the currently logged-in user
    ▪ /me/friends get a list of that person’s friends
    ▪ /me/music.listens get information about the music the person listens to
    ▪ /[place_id] get information about places where your users are
    Wednesday, May 29, 13

    View Slide

  23. Privacy & Permissions: Reading Data
    Wednesday, May 29, 13

    View Slide

  24. Privacy & Permissions: Reading Data
    Public
    Profile
    id, name, first_name, last_name, link, username, gender, locale
    Wednesday, May 29, 13

    View Slide

  25. Email
    Privacy & Permissions: Reading Data
    Public
    Profile
    id, name, first_name, last_name, link, username, gender, locale
    email
    Wednesday, May 29, 13

    View Slide

  26. Profile
    Properties
    Email
    Privacy & Permissions: Reading Data
    Public
    Profile
    id, name, first_name, last_name, link, username, gender, locale
    email
    user_about_me, user_activities, user_birthday,
    user_checkins, user_education_history, user_events,
    user_groups, user_hometown, user_interests,
    user_likes, user_location, user_notes, user_questions,
    user_relationships, user_relationship_details,
    user_religion_politics, user_status,
    user_subscriptions, user_videos, user_website,
    user_work_history, user_actions.music,
    user_actions.news, user_actions.video,
    user_games_activity, user_actions:APP_NAMESPACE
    Wednesday, May 29, 13

    View Slide

  27. Extended
    Profile
    Properties
    Email
    Privacy & Permissions: Reading Data
    Public
    Profile
    id, name, first_name, last_name, link, username, gender, locale
    email
    user_about_me, user_activities, user_birthday,
    user_checkins, user_education_history, user_events,
    user_groups, user_hometown, user_interests,
    user_likes, user_location, user_notes, user_questions,
    user_relationships, user_relationship_details,
    user_religion_politics, user_status,
    user_subscriptions, user_videos, user_website,
    user_work_history, user_actions.music,
    user_actions.news, user_actions.video,
    user_games_activity, user_actions:APP_NAMESPACE
    read_friendlists, read_insights, read_mailbox,
    read_requests, read_stream, xmpp_login, ads_management,
    create_event, manage_friendlists, manage_notifications,
    user_online_presence, friends_online_presence,
    publish_checkins, publish_actions, rsvp_event
    Wednesday, May 29, 13

    View Slide

  28. Privacy & Permissions:
    Trust is Key
    Wednesday, May 29, 13

    View Slide

  29. Privacy & Permissions:
    Trust is Key
    Wednesday, May 29, 13

    View Slide

  30. Privacy & Permissions:
    Trust is Key
    Wednesday, May 29, 13

    View Slide

  31. Easy publishing
    with the Feed Dialog
    Wednesday, May 29, 13

    View Slide

  32. Share Intent vs. Feed Dialog
    Wednesday, May 29, 13

    View Slide

  33. Share Intent vs. Feed Dialog
    Wednesday, May 29, 13

    View Slide

  34. Share Intent vs. Feed Dialog
    Wednesday, May 29, 13

    View Slide

  35. Demo
    Follow along:
    github.com/beardouglas/andevcon
    Wednesday, May 29, 13

    View Slide

  36. Deep Linking:
    The Way to Get Users from Facebook
    Wednesday, May 29, 13

    View Slide

  37. How Deep Linking Works
    Wednesday, May 29, 13

    View Slide

  38. How Deep Linking Works
    Users see stories generated
    by your app in their News
    Feed and engage with them
    Wednesday, May 29, 13

    View Slide

  39. How Deep Linking Works
    Users see stories generated
    by your app in their News
    Feed and engage with them
    Taken directly to
    app if the app is
    already installed
    Wednesday, May 29, 13

    View Slide

  40. How Deep Linking Works
    Users see stories generated
    by your app in their News
    Feed and engage with them
    Directed to Google
    Play to download app
    if it’s not installed
    Taken directly to
    app if the app is
    already installed
    Wednesday, May 29, 13

    View Slide

  41. Demo
    Wednesday, May 29, 13

    View Slide

  42. Uri target = getIntent().getData();
    if (target != null) {
    // target will contain target_url
    // matching story URL
    } else {
    // launched with no deep-link Uri
    }
    Wednesday, May 29, 13

    View Slide

  43. Get URL from Intent data from FB
    Direct users to the correct content
    inside your app
    Uri target = getIntent().getData();
    if (target != null) {
    // target will contain target_url
    // matching story URL
    } else {
    // launched with no deep-link Uri
    }
    Wednesday, May 29, 13

    View Slide

  44. Growing your app with Requests
    Wednesday, May 29, 13

    View Slide

  45. Wednesday, May 29, 13

    View Slide

  46. Wednesday, May 29, 13

    View Slide

  47. Wednesday, May 29, 13

    View Slide

  48. Wednesday, May 29, 13

    View Slide

  49. Demo
    Follow along:
    github.com/beardouglas/andevcon
    Wednesday, May 29, 13

    View Slide

  50. Pro Tips
    Wednesday, May 29, 13

    View Slide

  51. . Build stories worth sharing
    Wednesday, May 29, 13

    View Slide

  52. Wednesday, May 29, 13

    View Slide

  53. . Error-proof your sessions
    Wednesday, May 29, 13

    View Slide

  54. Session Lifecycle
    valid
    cache?
    new Session() CREATED_TOKEN_LOADED
    CREATED session.openFor…()
    session.open()
    OPENED
    success?
    CLOSED_LOGIN_FAILED
    OPENING
    Yes
    Yes
    No
    No
    Wednesday, May 29, 13

    View Slide

  55. Session Lifecycle (cont’d)
    session.requestNew…()
    session.close()
    OPENED
    success?
    OPENED
    Yes
    No
    CLOSED
    OPENED_TOKEN_UPDATED
    Wednesday, May 29, 13

    View Slide

  56. . Optimize for mobile
    Wednesday, May 29, 13

    View Slide

  57. Batching Requests
    Request
    Request
    Request RequestBatch
    public  void  setTimeout(int  timeoutInMilliseconds)
    Request
    Request
    Wednesday, May 29, 13

    View Slide

  58. http://a.url.can/go?here
    Optimize API calls
    Wednesday, May 29, 13

    View Slide

  59. http://a.url.can/go?here
    Optimize API calls
    /me?fields=photos.limit(25).fields(id,picture,tags)
    Wednesday, May 29, 13

    View Slide

  60. http://a.url.can/go?here
    Optimize API calls
    /me?fields=photos.limit(25).fields(id,picture,tags)
    Bundle requestParams = myPhotoRequest.getParameters();
    requestParams.putString("limit", "25");
    requestParams.putString("fields", "id,picture,tags");
    myPhotoRequest.setParameters(requestParams);
    Wednesday, May 29, 13

    View Slide

  61. . Design a social data model
    Wednesday, May 29, 13

    View Slide

  62. ‣What do you need?
    ‣When will you need it?
    ‣ How often do you expect that data to
    be updated?
    ‣What should you cache or store on your
    own database?
    ‣ Don’t use the Open Graph as a data store
    Social Data in your app
    Wednesday, May 29, 13

    View Slide

  63. ‣ User
    ‣ feed, friends, activities, interests,
    music, books, movies, television, likes,
    checkins, location, events
    ‣ Page
    ‣ name, category, picture.
    ‣ Permissions
    ‣ Payments
    ‣ Payment Subscriptions
    ‣ Errors
    https://developers.facebook.com/docs/reference/api/realtime/
    Realtime Updates
    Wednesday, May 29, 13

    View Slide

  64. Realtime Updates
    Wednesday, May 29, 13

    View Slide

  65. {
    "object": "user",
    "entry": [
    {
    "uid": 1335845740,
    "changed_fields": [
    "name",
    "picture"
    ],
    "time": 232323
    }, {
    "uid": 1234,
    "changed_fields": [
    "friends"
    ],
    "time": 232325
    }
    ]
    }
    Realtime Updates
    Wednesday, May 29, 13

    View Slide

  66. . Avoid common policy violations
    Wednesday, May 29, 13

    View Slide

  67. Avoid Common Policy Pitfalls
    ▪ Did the user know?
    ▪ Don’t pre-fill messages
    ▪ If you have a game that’s hosted on Facebook, be careful not to direct people off
    facebook.com to play the game or handle account issues
    ▪ Be cautious about data leaks when using external monetization and measuring
    toolkits
    ▪ Watch your spam ratings in the Insights dashboard
    Wednesday, May 29, 13

    View Slide

  68. https://graph.facebook.com/APP_ID
    /accounts/test-users?
    installed=true
    &name=FULL_NAME
    &locale=en_US
    &permissions=read_stream
    &method=post
    &access_token=APP_ACCESS_TOKEN
    {
    "id": "1234...",
    "access_token":"1234567..." ,
    "login_url":"https://www.facebook.com/
    platform/test_account..."
    "email": "[email protected]",
    "password": "1234..."
    }
    Don’t look like spam: work with test users
    Wednesday, May 29, 13

    View Slide

  69. https://graph.facebook.com/
    TEST_USER_1_ID/friends/
    TEST_USER_2_ID
    ?method=post
    &access_token=
    TEST_USER_1_ACCESS_TOKEN
    https://graph.facebook.com/
    TEST_USER_2_ID/friends/
    TEST_USER_1_ID
    ?method=post
    &access_token=
    TEST_USER_2_ACCESS_TOKEN
    Request Confirm
    Create networks of test users
    Wednesday, May 29, 13

    View Slide

  70. Facebook SDK .
    for Android
    developers.facebook.com/android
    github.com/fbsamples/android-3.0-howtos
    Wednesday, May 29, 13

    View Slide