Android facebook package name

Getting Started with the Facebook SDK for Android

This documentation explains how to get started integrating your Android app with Facebook by using the Facebook SDK for Android. The current version of the Facebook SDK for Android is version 12.0.0 and requires the Android API 15. For more information about versions and features, see Facebook SDK for Android.

Beginning with SDK v13.0, set to release in early 2022, a Client Token will be required for all calls to the Graph API.

You can set up your app to use the Facebook SDK for Android in the following ways:

  • By using the Quick Start.
  • By setting up your project with the Facebook SDK for Android.

Quick Start

To get a Facebook App ID, configure your app’s settings, and import the Facebook SDK for Android, click on the button below and follow the instructions.

Android Studio Setup

To use the Facebook SDK in an Android Studio project, add the SDK as a build dependency and import the SDK.

  1. Go to Android Studio | New Project | Minimum SDK.
  2. Select API 15: Android 4.0.3 (IceCreamSandwich) or higher and create your new project.
  3. After you create a new project, open Gradle Scripts | build.gradle (Project: and do the following:
    1. Add the following to the buildscript < repositories <>> section of the build.gradle (Project) file:
    2. Save and close build.gradle (Project: ) .
  4. Open Gradle Scripts | build.gradle (Module: app) and do the following:
    1. Add the following to the dependencies <> section of your build.gradle (module: app) file to compile the latest version of the Facebook SDK for Android:

      When you use the Facebook SDK, some events in your app are automatically logged and collected unless you disable automatic event logging. For details about what information is collected and how to disable automatic event logging, see Automatic App Event Logging.

      Add Your Facebook App ID and Client Token

      Add your Facebook App ID and Client Token to your project’s strings file and update your Android manifest:

      1. Open your /app/res/values/strings.xml file.

      2. Add a string element with the name attribute facebook_app_id and value as your Facebook App ID to the file. For example

      3. Open /app/manifests/AndroidManifest.xml

      4. Add a uses-permission element to the manifest:

      5. Add a meta-data element to the application element:

      Sending Images or Videos

      If you’re sharing links, images or video via the Facebook for Android app, you also need to declare the FacebookContentProvider in the manifest.

      Append your app id to the end of the authorities value. For example if your Facebook app id is 1234 , the declaration looks like:

      Running Sample Apps

      The following samples come with the Facebook SDK for Android:

      • HelloFacebookSample — Demonstrates profile access, status updates and photo upload.
      • RPSSample — Use Native Share Dialog, Open Graph publishing, pickers, invites, and deep linking.
      • Scrumptious — Login, requests, pickers, picture uploads, and Open Graph publishing.

      You can experiment with samples by importing the Facebook SDK into an Android Studio project. The samples have a project dependency rather than a central repository dependency via maven central or jcenter. This is so that when a local copy of the SDK gets updates, the samples reflect the changes.

      To run samples apps quickly, you can generate key hashes for your development environments. Add these to your Facebook developer profile for the sample apps. Keytool, for generating the key hashes, is included with the Java SE Development Kit (JDK) that you installed as part of setting up your development environment. OpenSSL is available for download from OpenSSL.

      On Windows, you need the following:

      Run the following command in a command prompt in the Java SDK folder. This generates a 28 character string.

      Go to the Facebook Developer site. Log into Facebook and, using the dropdown menu in the top-right, go to Developer Settings:

      In your developer settings, select Sample App from the menu, and add and save your key hash into your profile:

      You can add multiple key hashes if you develop with multiple machines.

      You can now compile and run all of the samples — including those that use Facebook Login.

      Create a Development Key Hash

      Facebook uses the key hash to authenticate interactions between your app and the Facebook app. If you run apps that use Facebook Login, you need to add your Android development key hash to your Facebook developer profile.

      For the version of your app that you release to you also need to generate and set a Release Key Hash.

      On either OS X or Windows you can get a key hash by generating it or by using the value returned by Settings.getApplicationSignature(Context) . For instructions, see Running Sample Apps .

      Create a Release Key Hash

      To authenticate the exchange of information between your app and the Facebook, you need to generate a release key hash and add this to the Android settings within your Facebook App ID. Without this, your Facebook integration may not work properly when you release your app to the store.

      In a previous step, you should have updated your Facebook Developer Settings with the key hashes for your development environments.

      When publishing your app, it is typically signed with a different signature to your development environment. Therefore, you want to make sure you create a Release Key Hash and add this to the Android settings for Facebook App ID.

      To generate a hash of your release key, run the following command on Mac or Windows substituting your release key alias and the path to your keystore.

      On Windows, you need the following:

      Run the following command in a command prompt in the Java SDK folder:

      Make sure to use the password that you set when you first created the release key.

      This command should generate a 28 characher string. Copy and paste this Release Key Hash into your Facebook App ID’s Android settings.

      You should also check that your Facebook App ID’s Android setting also contain the correct package name and main activity class for your Android package.

      Use the Facebook SDK for Android with Maven

      You can declare the Maven dependency with the latest available version of the Facebook SDK for Android.

      Troubleshooting Sample Apps

      If you have a problem running a sample app, it may be related to the key hash. You may see one of the following scenarios:

      • A native Login Dialog appears but after accepting the permissions you are still in a logged out state. The logcat also contains an exception:
      • A non-native Login Dialog appears with an error message: »..App is Misconfigured for facebook login. ».

      Check your key hash and you can make sure you use the correct key hash. I

      You can also manually modify the sample code to use the right key hash. For example in HelloFacebookSampleActivity class make a temporary change to the onCreate() :

      Save your changes and re-run the sample. Check your logcat output for a message similar to this:

      Save the key hash in your developer profile. Re-run the samples and verify that you can log in successfully.

      Источник

      Get Started – Android

      This guide shows you how to add App Events to your new or existing app by integrating the Facebook SDK then logging these events.

      Before You Start

      Step 1: Configure Your Facebook App

      Go to the App Dashboard, click My Apps, and create a new app if you don’t already have one. Navigate to Settings > Basic to view the App Details Panel with your App ID, your App Secret, and other details about your app.

      Set up your app for advertising by adding the following details:

      Save your changes.

      To learn more about adding details to your app, such as an icon or category, visit the App Development docs.

      To run ads and measure installs in the Ads Manager, you are required to associate at least one Ad Account with your app.

      1. In the app dashboard click Settings > Advanced.
      2. In Authorized Ad Account IDs, add your Ad Account IDs. You can get your ad account IDs from your Ads Manager.
      3. If you also have a business account, in Authorized Businesses, add your Business Manager ID. You can find your Business Manager ID in the URL of your Business Manager.

      Step 3: Integrate the Facebook SDK in Your Android App

      If you’re adding the SDK to an existing project, start at step 3.

      1. Go to Android Studio | Start a new Android Studio project | Application name | Minimum SDK.
      2. Select API 15: Android 4.0.3 9 (IceCreamSandwich) or higher and click Next.
      3. Click Basic Activity and then click Next, and then Finish.
      4. In your project, open | Gradle Scripts | build.gradle (Project) and add the following to the buildscript < repositories <>> section to download the SDK from the Maven Central Repository:

      Step 4: Add App Events

      There are three ways events are tracked in your app:

      Automatically Logged Events

      When you use the Facebook SDK, certain events in your app are automatically logged and collected for Facebook unless you disable automatic event logging. These events are relevant for all use cases — targeting, measurement and optimization. There are three key events collected as part of the Automatic App Event Logging: App Install, App Launch, and Purchase. When automatic logging is enabled, advertisers are able to disable these events, as well as other Facebook internal events such as login impression events. However, if you have disabled automatic logging, but still want to log specific events, such as install or purchase events, manually implement logging for these events in your app.

      The first time a new person activates your app or the first time your app starts on a particular device.

      When a person launches your app, the Facebook SDK is initialized and the event is logged. However, if a second app launch event occurs within 60 seconds of the first, the second app launch event is not logged.

      For the Facebook SDK for Android v4.18, and earlier, SDK initialization is a manual process that differs from the manual event logging process described in this doc. Please upgrade to the latest SDK version or scroll to the Legacy SDK Initialization section to add events manually.

      When a purchase processed by Google Play has been completed. If you use other payments platforms, add purchase event code manually.

      In-app purchase logging is automatically enabled for apps that have installed or upgraded to v4.39. For apps running an earlier version, enable in-app purchase events in Basic > Settings Android card in the app dashboard or add the purchase event code manually.

      Facebook SDK Crash Report

      (For Facebook Use Only.)

      If your app crashed due to the Facebook SDK, a crash report is generated and sent to Facebook when your app is restarted. This report contains no user data and helps Facebook ensure the quality and stability of the SDK. To opt out of logging this event, disable automatically logged events.

      Facebook SDK ANR Report

      (For Facebook Use Only.)

      If your app has an ANR (Application Not Responding) due to the Facebook SDK, an ANR report is generated and sent to Facebook when your app is restarted. This report contains no user data and helps Facebook ensure the quality and stability of the SDK. To opt out of logging this event, disable automatically logged events.

      Disable Automatically Logged Events

      To disable automatically logged events add the following to your AndroidManifest.xml file:

      In some cases, you want to delay the collection of automatically logged events, such as to obtain user consent or fulfill legal obligations, instead of disabling it. In this case, call the setAutoLogAppEventsEnabled() method of the FacebookSDK class and set to true to re-enable event logging after the end-user provides consent.

      To suspend logging again for any reason, set the setAutoLogAppEventsEnabled() method to false .

      You can also disable automatic In-App Purchase event logging using the app dashboard. Go to the Android card under Basic > Settings and toggle the switch to No.

      Disable Automatic SDK Initialization

      To disable automatic SDK initialization, add the following to your AndroidManifest.xml file:

      In some cases, you want to delay the SDK initialization, such as to obtain user consent or fulfill legal obligations, instead of disabling it. In this case, call the class method setAutoInitEnabled and set it to true to manually initialize the SDK after the end-user provides consent.

      Disable Collection of Advertiser IDs

      To disable collection of advertiser-id , add the following to your AndroidManifest.xml file:

      In some cases, you want to delay the collection of advertiser_id , such as to obtain User consent or fulfill legal obligations, instead of disabling it. In this case, call the setAdvertiserIDCollectionEnabled() method of the FacebookSDK class and set it to true to re-enable collection of advertiser_id after the end-user provides consent.

      To suspend collection for any reason, set the setAdvertiserIDCollectionEnabled() method to false .

      Manually Log Events

      Create an AppEventsLogger object using the helper methods to log your events, where this is the Activity your method is in.

      You can then log your event to logger , where AppEventConstants.EVENT_NAME_X is one of the constants shown in the Standard Events table or from the Code Generator code.

      You can also specify a set of parameters in a Bundle and a valueToSum property which is an arbitrary number that can represent any value, for example, a price or a quantity. When reported, all of the valueToSum properties are summed together. For example, if 10 people purchased one item and each item cost $10 (and passed in valueToSum ) then they would be added together to report $100.

      Note, both valueToSum and parameters are optional.

      To log a custom event, just pass the name of the event as a string. This function assumes that logger is an instance of AppEventsLogger and has been created using AppEventsLogger.newLogger() call.

      Event Parameters

      Each event can be logged with a valueToSum and a set of up to 25 parameters. They are passed via a Bundle where the key holds the parameter name and the value either a String or an int . If you provide another type of value that is not compliant such as a boolean , the SDK logs a warning to LogginBehavior.APP_EVENT .

      Refer to the Standard Event Parameters Reference guide for parameters typically used with standard events. These parameters are intended to provide guidance, however, you can provide your own parameters as well. Your app should log parameters that you are interested in seeing breakdowns for in insights.

      Do not use «event» as the name of a parameter. Custom parameters with the name «event» will not be logged. Use another name or add a prefix or suffix to the name, such as my_custom_event .

      Step 5: Test Your Event Logging

      The App Ads Helper allows you to test the app events in your app to ensure that your app is sending events to Facebook.

      1. Open the App Ads Helper.
      2. In Select an App, choose your app and choose Submit.
      3. Go to the bottom and choose Test App Events.
      4. Start your app and send an event. The event appears on the web page.

      Enabling Debug Logs

      Enable debug logs to verify App Event usage from the client side. The debug logs contain detailed requests and JSON responses. Enable debug logs by adding the following code after initializing the Facebook SDK for Android:

      This is only for debugging purposes. Please disable debug logs before deploying your app to the public.

      Learn More

      For more information and helpful hints on App Events check out:

      Example Apps

      We have created some examples for different app types to show you how you can use app events. Each of the example apps provides a screen by screen breakdown of the different events with code examples. It is important to note that these examples are a starting point for your app and should be customized by you.

      Источник

      Читайте также:  Microsoft office android patched
Оцените статью