What is facebook android sdk

Getting started with the Facebook for Android SDK

Many mobile apps allow the user to post content to popular social media platforms, such as Facebook, Twitter and LinkedIn.

This kind of social sharing can be a great way to promote your app, and can improve the user experience by creating a connection between your application and the user’s favorite social media networks.

To promote social sharing, many of the major social platforms have created tools that specifically target app developers – and Facebook is no exception!

In this article, I’ll show you how to add Facebook integration to your Android applications, using the Facebook for Android SDK (Software Development Kit). Once you’re connected to the official Facebook SDK, you’ll have access to a wide range of features, but in this article we’ll be focusing on two of the most popular: authenticating with Facebook, and social sharing.

By the end of this article, you’ll have created an application that allows users to authenticate their identify using their Facebook credentials, and then share your app’s content, by posting it to Facebook.

What is the Facebook for Android SDK?

Every social media platform wants to drive user engagement, and enabling users to share content from a range of sources is a powerful way to keep them engaged with your platform.

The official Facebook SDK for Android helps you create apps that integrate with Facebook, and provides access to several key features, including Facebook authentication, and reading and writing to the platform’s APIs.

The Facebook SDK for Android compromises of the following components:

  • Analytics. Provides access to aggregated and anonymized data, so you can analyze how people are using your app.
  • Login. Allows people to sign into your app using their Facebook credentials. If the user is already signed into the Facebook for Android mobile app, then they won’t have to re-enter their username and password, in order to authenticate with your application. Once a user is signed in with Facebook, you can retrieve information and perform actions on their behalf, such as displaying their Facebook profile pic inside your app, or posting status updates.
  • Account Kit. Makes it possible for users to authenticate their identify, using just their phone number or email address. Account Kit doesn’t require a Facebook account, which makes this a viable authentication method for any users who haven’t signed up to Facebook.
  • Ads. If you want to monetize your application, then you can use this component to create and run ad campaigns.
  • App events. Allows you to track a range of user actions and events within your app. You can use this information to evaluate the effectiveness of your Mobile App Ads, or to identify the users who are most likely to respond to your adverts.
  • App Links. Imagine a user has just posted some of your app’s content to Facebook; App Links let you specify what happens, when someone interacts with this content. For example, they might get forwarded to your app’s Google Play listing, or your company’s website. Alternatively, if someone already has your app installed on their device, then you may respond by launching your application, and taking them to an Activity related to this content.
  • Graph API. By integrating with the Facebook Graph API, you can retrieve data from the Facebook platform, and add data such as posting new stories and uploading photos.
Читайте также:  Камера с галереей android

What are the benefits of Facebook integration?

For developers, the Facebook for Android SDK has several benefits.

1. Seamless sign up

Depending on your application, users may need to authenticate their identity before they can access certain features. Even if your application only requires an email address and password, there’s always going to be a percentage of mobile users who decide this is too much hassle, and exit your application.

There’s several reasons why we’re much less likely to complete a registration form on a mobile device, compared to our laptop or computer. Firstly, we tend to use smartphones and tablets on the go, and often under time constraints, for example you might spend a few minutes playing on your phone while you’re waiting at the doctor’s office, in line at the supermarket, or at your local bus stop. None of these scenarios are ideal for completing an in-app form!

In addition, typing on your mobile device’s small, virtual keyboard can be time-consuming and frustrating, particularly for users who have manual dexterity issues, or anyone who’s prone to typos. Typing a password that contains a mixture of symbols, numbers, and upper and lowercase letters, can feel like a huge effort on your smartphone or tablet.

By adding Facebook login to your application, you can replace an in-app registration form, with single-tap authentication.

Источник

What is facebook android sdk

Facebook SDK for Android

This open-source library allows you to integrate Facebook into your Android app.

Learn more about the provided samples, documentation, integrating the SDK into your app, accessing source code, and more at https://developers.facebook.com/docs/android

  1. Check-out the tutorials available online at https://developers.facebook.com/docs/android/getting-started
  2. Start coding! Visit https://developers.facebook.com/docs/android/ for tutorials and reference documentation.

The SDK is separated into modules with the following structure.

Facebook SDKs are broken up into separate modules as shown above. To ensure the most optimized use of space only install the modules that you intend to use. To get started, see the Installation section below.

Any Facebook SDK initialization must occur only in the main process of the app. Use of Facebook SDK in processes other than the main process is not supported and will likely cause problems.

Facebook SDKs are published to Maven as independent modules. To utilize a feature listed above include the appropriate dependency (or dependencies) listed below in your app/build.gradle file.

You may also need to add the following to your project/build.gradle file.

You can also visit our Facebook Developer Community Forum, join the Facebook Developers Group on Facebook, ask questions on Stack Overflow, or open an issue in this repository.

See the SECURITY POLICY for more info on our bug bounty program.

We are able to accept contributions to the Facebook SDK for Android. To contribute please do the following.

  • Follow the instructions in the CONTRIBUTING.md.
  • Submit your pull request to the main branch. This allows us to merge your change into our internal main and then push out the change in the next release.
Читайте также:  Как отключить мегафон про андроид

Except as otherwise noted, the Facebook SDK for Android is licensed under the Facebook Platform License (https://github.com/facebook/facebook-android-sdk/blob/main/LICENSE.txt).

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an «AS IS» BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

By enabling Facebook integrations, including through this SDK, you can share information with Facebook, including information about people’s use of your app. Facebook will use information received in accordance with our Data Use Policy (https://www.facebook.com/about/privacy/), including to provide you with insights about the effectiveness of your ads and the use of your app. These integrations also enable us and our partners to serve ads on and off Facebook.

You may limit your sharing of information with us by updating the Insights control in the developer tool (https://developers.facebook.com/apps/[app_id]/settings/advanced).

If you use a Facebook integration, including to share information with us, you agree and confirm that you have provided appropriate and sufficiently prominent notice to and obtained the appropriate consent from your users regarding such collection, use, and disclosure (including, at a minimum, through your privacy policy). You further agree that you will not share information with us about children under the age of 13.

You agree to comply with all applicable laws and regulations and also agree to our Terms (https://www.facebook.com/policies/), including our Platform Policies (https://developers.facebook.com/policy/) and Advertising Guidelines, as applicable (https://www.facebook.com/ad_guidelines.php).

By using the Facebook SDK for Android you agree to these terms.

Источник

Подключаем Facebook SDK для Xamarin.Forms

Социальные сети, и особенно Facebook, уже давно используются в мобильных приложениях. Сегодня мы рассмотрим, как подключить нативные Facebook SDK к проекту на базе Xamarin.Forms (iOS и Android) для удобной авторизации пользователей и получения о них базовой информации. Вы также легко сможете расширить описанные в статье методы для того, чтобы реализовать полноценное взаимодействие с этим замечательным сервисом. Тема простая и понятная, поэтому без теорий и прелюдий перейдем сразу к практике.

Создаем приложение в Facebook

Для тех, кто впервые создает своё приложение в Facebook, мы кратко расскажем о том, как это делается.

Сам по себе процесс это довольно простой и потребует от вас следующих данных:

  • Package Name для Android-проекта (например, com.binwell.login )
  • Bundle Identifier для iOS-проекта (например, com.binwell.login )

Для Android ещё потребуются Key Hashes, которые можно получить командой:

Вместо [USERNAME] необходимо подставить ваше имя пользователя в системе. Плюс можно прописать путь до openssl , если путь до него не указан в PATH . Скачать openssl для Windows можно здесь.

На выходе мы и получим нужные Key Hashes следующего вида: kGP2WMxohvxm/NiwR7H+Eb3/8qw=

Теперь заходим на developers.facebook.com и создаём новое приложение. Отдельно для iOS и Android. При создании приложения мы можем использовать режим с подсказками (Quick Start), где дополнительно описано как настроить проект. Из этого руководства нам и потребуются примеры кода.

Подключаем Facebook SDK к проектам iOS и Android

Для начала необходимо установить пакеты Facebook SDK от Xamarin для iOS и Android из Nuget:

Обратите внимание, что с Xamarin.Forms 2.3 на текущий момент совместима только версия Xamarin.Facebook.Android 4.11.0.1. Версия Xamarin.Facebook.iOS ограничений по совместимости не имеет.

Читайте также:  Подводная лодка для андроида

Подключаем в Android

Для начала нам необходимо прописать специальные значения в файле Resources/values/strings.xml :

Где, 1102463466549096 это ваш App ID из настроек приложения Facebook. Дополнительно нам потребуется внести следующие изменения в AndroidManifest.xml :

Далее вносим небольшие доработки в MainActivity.cs :

На этом первичная инициализация Facebook SDK завершена.

Подключаем в iOS

По аналогии с Android, нам будет необходимо внести правки в файл Info.plist , вставить следующие строки между . :

И немного кода в AppDelegate.cs :

На этом предварительная подготовка завершена и мы можем переходить к использованию Facebook SDK в нашем приложении.

Интегрируем с Xamarin.Forms

Использовать Facebook SDK мы будем через механизм DependencyService . Для этого в первую очередь опишем нужные данные и интерфейс сервиса:

Одной из целей подключения социальных сетей является возможность простого и удобного получения пользовательских данных, поэтому нам потребуется дополнительный запрос для получения email, который Facebook не отдает по умолчанию. Данные запросы будет необходимо реализовать отдельно для каждой платформы.

Реализация для Android

Для Android реализация интерфейса выглядит следующим образом:

Дополнительно потребуется добавить обработчик в MainActivity.cs :

Реализация для iOS

Делаем реализацию интерфейса для Facebook iOS SDK.

Подключаем в Xamarin.Forms

Для доступа к созданным реализациям достаточно вставить следующий обработчик события Clicked для кнопки «Facebook Login»:

На этом кодирование завершено!

Используем

Итак, волнительный момент. Делаем сборку, запускаем и… легко авторизуемся с помощью нативных SDK.

Полный код проекта с пошаговыми изменениями расположен в репозитории на Bitbucket.

Итак, сегодня мы подключили нативные Facebook SDK к приложению на Xamarin.Forms. Уже работает авторизация и получение базовой информации о пользователе, но при желании вы можете легко расширить набор методов для доступа ко всем возможностям Facebook SDK. В следующий раз мы возьмем задачку поинтересней и подключим нативные ВКонтакте SDK.

Оставайтесь на связи, задавайте ваши вопросы в комментариях и вступайте в группу Xamarin Developers в Telegram!

Об авторе

Вячеслав Черников — руководитель отдела разработки компании Binwell. В прошлом — один из Nokia Champion и Qt Certified Specialist, в настоящее время — специалист по платформам Xamarin и Azure. В сферу mobile пришел в 2005 году, с 2008 года занимается разработкой мобильных приложений: начинал с Symbian, Maemo, Meego, Windows Mobile, потом перешел на iOS, Android и Windows Phone.

Источник

Component SDKs of the Facebook SDK for Android

The Facebook SDK for Android consists of the following component SDKs:

If you don’t need the functionality of the full Facebook SDK for Android, you can save space by using only the component SDKs that you need to support the Facebook products that you want to use in your app.

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.

To link with Maven to one of the component SDKs in your project, add one of the following implementation statements to your build script:

  • implementation ‘com.facebook.android:facebook-applinks:latest.release’
  • implementation ‘com.facebook.android:facebook-common:latest.release’
  • implementation ‘com.facebook.android:facebook-core:latest.release’
  • implementation ‘com.facebook.android:facebook-gamingservices:latest.release’
  • implementation ‘com.facebook.android:facebook-login:latest.release’
  • implementation ‘com.facebook.android:facebook-messenger:latest.release’
  • implementation ‘com.facebook.android:facebook-share:latest.release’

To add an implementation statement:

    In your project, open your_app | Gradle Scripts | build.gradle (Project) and add the following repository to the buildscript < repositories <>> section to download the SDK from the Maven Central Repository:

Download

You can also download the entire Facebook SDK for Android.

Источник

Оцените статью