/ios-android-requests-bestpractices

Guides you through the best practices for sending Facebook Requests on Android and iOS.

Primary LanguageObjective-C

Requests Best Practcies (for iOS and Android)

Guides you through the best practices for sending Facebook Requests on Android and iOS.

Authors: Christine Abernathy (caabernathy)

Installing

This section will walk you through the following:

  • Getting Started
  • Creating your Facebook app
  • Installing the iOS app
  • Installing the Android app

Getting Started

Your install package should have the following files:

  • Requests iOS Project (iOS)

  • MyRequests Project (Android)

To get the sample code do the following:

  • Install Git.

  • Pull the samples package from GitHub:

    git clone git://github.com/fbsamples/native-requests-best-practices

Creating your Facebook app

First set up a Facebook app using the Developer app:

  • Create a new Facebook app
  • (Optional) Enter the App Namespace when creating your app. You can choose a simple string to identify your app, such as ''requests'', but it must be unique.
  • Enter an App Domain setting that corresponds to your domain.
  • Enter a Mobile Web URL. For testing purposes set it to a URL in your domain.
  • Configure the Native iOS App settings
    • Enter a iOS Bundle ID. This should be of the form com.example.samples.requests where example corresponds to your domain. You should note this bundle ID because it needs to match the Bundle identifier in the Xcode project.
    • Enter a value for the iPhone App Store ID. The value must correspond to any valid iTunes app ID.
    • Enter "0" in the iPad App Store ID setting.
    • Enable the Configured for iOS SSO setting.
  • Configure the Native Android App settings.
    • Enable the Configured for Android SSO setting.
    • Enter you app's signature in the Android Key Hash field. For more information see the Android Tutorial.
    • Enter "com.facebook.samples.requests" in the Android Package Name setting.
    • Enter "com.facebook.samples.requests.App" in the Android Class Name setting.
    • Enter a value for the Android Market URI. The value must correspond to any valid Google Play URL.

Installing the iOS app

  1. Get the latest Facebook iOS SDK from GitHub: git clone git://github.com/facebook/facebook-ios-sdk.git

  2. Using Xcode open up Requests/Requests.xcodeproj

  3. Include the Facebook iOS SDK:

    1. The Facebook iOS SDK package should include a folder, facebook-ios-sdk/src
    2. Drag the src folder to the Requests project. You may choose to copy the items over into your project.
  4. Set up your App ID:

    1. Open up AppDelegate.m, add your app ID by changing:

         static NSString *kAppId = @"264966473580049";
      

    to:

          static NSString *kAppId = @"YOUR_APP_ID";
    
    1. Open up Requests/Supporting Files/Requests-Info.plist
    2. Navigate to URL types > Item 0 > URL Schemes > Item 0
    3. Replace fbYOUR_APP_ID with "fb" followed by your app ID, e.g. fb123456 if your app ID is 123456
  5. Set up your Bundle Identifier:

    1. Open up Requests/Supporting Files/Requests-Info.plist
    2. Edit the Bundle identifier information and make sure it matches the settings in the Facebook Dev App
  6. Build and run the application. If you have any issues check out the iOS Tutorial.

Installing the Android app

  1. Get the latest Facebook Android SDK from GitHub: git clone git://github.com/facebook/facebook-android-sdk.git

  2. Launch Eclipse

  3. Create a Facebook Android SDK Project:

    1. From the Eclipse menu, navigate to File > New > Android Project
    2. Select "Create project from existing source"
    3. The Facebook Android SDK package should include a folder, facebook-android-sdk/facebook
    4. Browse to the facebook folder and select it
    5. Click Next
    6. Select Android 2.2 as the Build Target
    7. Click Finish
  4. Import the sample app:

    1. From the Eclipse menu, navigate to File > Import
    2. Select General > Existing Projects into Workspace
    3. The sample package should include a folder, Android/MyRequests
    4. Browse to the MyRequest folder and select it
    5. Click Finish
  5. Include the Facebook Android SDK:

    1. From the Eclipse Package Explorer, select the MyRquests project
    2. Right-click and select the Properties menu
    3. In the Library section, click Add
    4. Select com_facebook_android
    5. Click OK
    6. Click OK to exit the Properties dialog
  6. Set up your App ID:

    1. From the Eclipse Package Explorer, select the MyRequests project

    2. Open up App.java (under the src/com.facebook.samples.requests folder)

    3. Change the existing app ID:

         public static final String APP_ID = "264966473580049";
      

    to:

          public static final String APP_ID = "YOUR_APP_ID";
    
  7. Install the Facebook app. Go to the Android Tutorial to find more instructions on this.

  8. Run the application as an Android Application. If you have any issues check out the Android Tutorial.

Contributing

All contributors must agree to and sign the Facebook CLA prior to submitting Pull Requests. We cannot accept Pull Requests until this document is signed and submitted.

License

Copyright 2012-present Facebook, Inc.

You are hereby granted a non-exclusive, worldwide, royalty-free license to use, copy, modify, and distribute this software in source code or binary form for use in connection with the web services and APIs provided by Facebook.

As with any software that integrates with the Facebook platform, your use of this software is subject to the Facebook Developer Principles and Policies [http://developers.facebook.com/policy/]. This copyright notice shall be included in all copies or substantial portions of the software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.