Com facebook android sdk

Содержание
  1. Подключаем Facebook SDK для Xamarin.Forms
  2. Создаем приложение в Facebook
  3. Подключаем Facebook SDK к проектам iOS и Android
  4. Подключаем в Android
  5. Подключаем в iOS
  6. Интегрируем с Xamarin.Forms
  7. Реализация для Android
  8. Реализация для iOS
  9. Подключаем в Xamarin.Forms
  10. Используем
  11. Об авторе
  12. Facebook SDK for Android Upgrade Guide
  13. Upgrading the Android SDK to 5.0.0 and beyond
  14. Upgrading the Android SDK from 4.40.0 to 4.41.0
  15. Upgrading the Android SDK from 4.39.1 to 4.40.0
  16. Upgrading the Android SDK from 4.38.1 to 4.39.0
  17. Upgrading the Android SDK from 4.38.0 to 4.38.1
  18. Upgrading the Android SDK from 4.37.0 to 4.38.0
  19. Upgrading the Android SDK from 4.37.0 to 4.37.0
  20. Upgrading the Android SDK from 4.36.1 to 4.37.0
  21. Upgrading the Android SDK from 4.36.0 to 4.36.1
  22. Upgrading the Android SDK from 4.35.0 to 4.36.0
  23. Upgrading the Android SDK from 4.34.0 to 4.35.0
  24. Upgrading the Android SDK from 4.33.0 to 4.34.0
  25. Upgrading the Android SDK from 4.32.0 to 4.33.0
  26. Upgrading the Android SDK from 4.31.0 to 4.32.0
  27. Upgrading the Android SDK from 4.30.0 to 4.31.0
  28. Upgrading the Android SDK from 4.29.0 to 4.30.0
  29. Upgrading the Android SDK from 4.28.0 to 4.29.0
  30. Upgrading the Android SDK from 4.27.0 to 4.28.0
  31. Upgrading the Android SDK from 4.26.0 to 4.27.0
  32. Facebook SDK
  33. Account Kit SDK
  34. Upgrading the Android SDK from 4.25.0 to 4.26.0
  35. Upgrading the Android SDK from 4.24.0 to 4.25.0
  36. Upgrading the Android SDK from 4.23.0 to 4.24.0
  37. Upgrading the Android SDK from 4.22.1 to 4.23.0
  38. Upgrading the Android SDK from 4.22.0 to 4.22.1
  39. Upgrading the Android SDK from 4.21.1 to 4.22.0
  40. Facebook SDK
  41. Account Kit SDK
  42. Upgrading the Android SDK from 4.21.0 to 4.21.1
  43. Upgrading the Android SDK from 4.20.0 to 4.21.0
  44. Upgrading the Android SDK from 4.19.0 to 4.20.0
  45. Upgrading the Android SDK from 4.18.0 to 4.19.0
  46. Android SDK
  47. Account Kit SDK
  48. Audience Network SDK
  49. Upgrading the Android SDK from 4.17.0 to 4.18.0
  50. Upgrading the Android SDK from 4.16.1 to 4.17.0
  51. Upgrading the Android SDK from 4.16.0 to 4.16.1
  52. Upgrading the Android SDK from 4.15.0 to 4.16.0
  53. Upgrading the Android SDK from 4.14.1 to 4.15.0
  54. Upgrading the Android SDK from 4.14.0 to 4.14.1
  55. Upgrading the Android SDK from 4.13.2 to 4.14.0
  56. Upgrading the Android SDK from 4.13.1 to 4.13.2
  57. Upgrading the Android SDK from 4.13.0 to 4.13.1
  58. Upgrading the Android SDK from 4.12.1 to 4.13.0
  59. Upgrading the Android SDK from 4.12.0 to 4.12.1
  60. Upgrading the Android SDK from 4.11.0 to 4.12.0
  61. Upgrading the Android SDK from 4.10.1 to 4.11.0
  62. Upgrading the Android SDK from 4.10.0 to 4.10.1
  63. Upgrading the Android SDK from 4.9.0 to 4.10.0
  64. Upgrading the Android SDK from 4.8.2 to 4.9.0
  65. Upgrading the Android SDK from 4.8.1 to 4.8.2
  66. Upgrading the Android SDK from 4.8.0 to 4.8.1
  67. Upgrading the Android SDK from 4.7.0 to 4.8.0
  68. Upgrading the Android SDK from 4.6.0 to 4.7.0
  69. Upgrading the Android SDK from 4.5.1 to 4.6.0
  70. Upgrading the Android SDK from 4.5.0 to 4.5.1
  71. Upgrading the Android SDK from 4.4.1 to 4.5.0
  72. Upgrading the Android SDK from 4.4.0 to 4.4.1
  73. Upgrading the Android SDK from 4.3.0 to 4.4.0
  74. Upgrading the Android SDK from 4.2.0 to 4.3.0
  75. Upgrading the Android SDK from 4.1.2 to 4.2.0
  76. Upgrading the Android SDK from 4.1.1 to 4.1.2
  77. Upgrading the Android SDK from 4.1.0 to 4.1.1
  78. Upgrading the Android SDK from 4.0.1 to 4.1.0
  79. Upgrading the Android SDK from 4.0 to 4.0.1
  80. Upgrading the Android SDK from 3.x to 4.x
  81. Install and Setup Updates
  82. Login Updates
  83. Graph API Updates
  84. Sharing Updates

Подключаем 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:

Читайте также:  Формат chm для андроида

Обратите внимание, что с 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.

Источник

Facebook SDK for Android Upgrade Guide

Upgrading the Android SDK to 5.0.0 and beyond

Upgrading the Android SDK from 4.40.0 to 4.41.0

No special steps are required to upgrade to 4.41.0.

Upgrading the Android SDK from 4.39.1 to 4.40.0

No special steps are required to upgrade to 4.40.0.

Upgrading the Android SDK from 4.38.1 to 4.39.0

No special steps are required to upgrade to 4.39.0.

Upgrading the Android SDK from 4.38.0 to 4.38.1

No special steps are required to upgrade to 4.38.1.

Upgrading the Android SDK from 4.37.0 to 4.38.0

No special steps are required to upgrade to 4.38.0.

Upgrading the Android SDK from 4.37.0 to 4.37.0

No special steps are required to upgrade to 4.37.0.

Upgrading the Android SDK from 4.36.1 to 4.37.0

No special steps are required to upgrade to 4.37.0.

Upgrading the Android SDK from 4.36.0 to 4.36.1

No special steps are required to upgrade to 4.36.1.

Upgrading the Android SDK from 4.35.0 to 4.36.0

No special steps are required to upgrade to 4.36.0.

Upgrading the Android SDK from 4.34.0 to 4.35.0

No special steps are required to upgrade to 4.35.0.

Upgrading the Android SDK from 4.33.0 to 4.34.0

No special steps are required to upgrade to 4.34.0.

Upgrading the Android SDK from 4.32.0 to 4.33.0

No special steps are required to upgrade to 4.33.0.

Upgrading the Android SDK from 4.31.0 to 4.32.0

No special steps are required to upgrade to 4.32.0.

Upgrading the Android SDK from 4.30.0 to 4.31.0

No special steps are required to upgrade to 4.31.0.

Upgrading the Android SDK from 4.29.0 to 4.30.0

Account Kit preferences API is deprecated. After upgrading to graph api v1.3 you will not longer be able to store key-value pairs on user preferences.

Upgrading the Android SDK from 4.28.0 to 4.29.0

No special steps are required to upgrade to 4.29.0.

Upgrading the Android SDK from 4.27.0 to 4.28.0

No special steps are required to upgrade to 4.28.0.

Upgrading the Android SDK from 4.26.0 to 4.27.0

Facebook SDK

  • Update any references to GraphRequest.createOpenGraphObject(ShareOpenGraphObject) to ShareGraphRequest.createOpenGraphObject(ShareOpenGraphObject) instead.
  • Update any references to FacebookSDK.[set|get]WebDialogTheme(. ) to WebDialog.[set|get]WebDialogTheme(. ) .

Account Kit SDK

No special steps are required to upgrade to 4.27.0.

Upgrading the Android SDK from 4.25.0 to 4.26.0

No special steps are required to upgrade to 4.26.0.

Upgrading the Android SDK from 4.24.0 to 4.25.0

No special steps are required to upgrade to 4.25.0.

Upgrading the Android SDK from 4.23.0 to 4.24.0

No special steps are required to upgrade to 4.24.0.

Читайте также:  Андроид без камеры 2021

Upgrading the Android SDK from 4.22.1 to 4.23.0

No special steps are required to upgrade to 4.23.0.

Upgrading the Android SDK from 4.22.0 to 4.22.1

No special steps are required to upgrade to 4.22.1.

Upgrading the Android SDK from 4.21.1 to 4.22.0

Facebook SDK

The title , description , caption and image field of FBSDKShareLinkContent have been deprecated. Please take appropriate action to remove usage of them.

Account Kit SDK

Remove the loginType parameter from constructor of SkinManager when assigning a new UI Manager. When using SkinManager , you no longer need to specify the AppLoginTheme for AccountKitActivity in AndroidManifext.xml .

Upgrading the Android SDK from 4.21.0 to 4.21.1

No special steps are required to upgrade to 4.21.1.

Upgrading the Android SDK from 4.20.0 to 4.21.0

No special steps are required to upgrade to 4.21.0.

Upgrading the Android SDK from 4.19.0 to 4.20.0

No special steps are required to upgrade to 4.20.0.

Upgrading the Android SDK from 4.18.0 to 4.19.0

Android SDK

The Facebook SDK is now auto initialized on Application start. If you are using the Facebook SDK in the main process and don’t need a callback on SDK initialization completion you can now remove calls to FacebookSDK.sdkInitialize. If you do need a callback, you should manually invoke the callback in your code.

Basic App Events are now logged after initializing the Facebook SDK. Calls to activateApp can now be removed from your application. This feature can be disabled by following the instructions in App Events docs.

The LoginButton UI is changed in 4.19.0. Instead of «Log in with Facebook», the button now displays «Continue with Facebook». The button color is changed to #4267B2 from #3B5998. The button height is decreased from 30dp to 28dp due to use of smaller font size and paddings around a larger Facebook logo.

The interface for using LoginButton remains the same. Please take time to ensure the updated LoginButton does not break your app’s UX

Account Kit SDK

The Account Kit SDK is now auto initialized on Application start. If you are using the Account Kit SDK in the main process and don’t need a callback on SDK initialization completion you can now remove calls to AccountKit.initialize. If you do need a callback, you should manually invoke the callback in your code.

Audience Network SDK

No special steps are required to upgrade to 4.19.0.

Upgrading the Android SDK from 4.17.0 to 4.18.0

No special steps are required to upgrade to 4.18.0.

Upgrading the Android SDK from 4.16.1 to 4.17.0

If you use Account Kit Advanced UI, make sure to handle the three new screens as noted in the docs.

Upgrading the Android SDK from 4.16.0 to 4.16.1

No special steps are required to upgrade to 4.16.1.

Upgrading the Android SDK from 4.15.0 to 4.16.0

No special steps are required to upgrade to 4.16.0.

Upgrading the Android SDK from 4.14.1 to 4.15.0

Classes and methods associated with App and Game Groups have been deprecated. Please take appropriate action to remove usage of them.

Upgrading the Android SDK from 4.14.0 to 4.14.1

No special steps are required to upgrade to 4.14.1.

Upgrading the Android SDK from 4.13.2 to 4.14.0

No special steps are required to upgrade to 4.14.0.

Upgrading the Android SDK from 4.13.1 to 4.13.2

No special steps are required to upgrade to 4.13.2.

Upgrading the Android SDK from 4.13.0 to 4.13.1

No special steps are required to upgrade to 4.13.1.

Upgrading the Android SDK from 4.12.1 to 4.13.0

No special steps are required to upgrade to 4.13.0.

Upgrading the Android SDK from 4.12.0 to 4.12.1

No special steps are required to upgrade to 4.12.1.

Upgrading the Android SDK from 4.11.0 to 4.12.0

No special steps are required to upgrade to 4.12.0.

Upgrading the Android SDK from 4.10.1 to 4.11.0

Instead of calling AppEventsLogger.activateApp and AppEventsLogger.deactivateApp in each Activity, you should now just call AppEventsLogger.activateApp(Application) from your Application’s onCreate method and the SDK will automatically track sessions for you.

Note the v4.11 SDK targets v2.6 of the Graph API.

Upgrading the Android SDK from 4.10.0 to 4.10.1

No special steps are required to upgrade to 4.10.1.

Upgrading the Android SDK from 4.9.0 to 4.10.0

If you relied on graph requests being localized. You now have to specify the locale parameter manually.

Upgrading the Android SDK from 4.8.2 to 4.9.0

No special steps are required to upgrade to 4.9.0.

Upgrading the Android SDK from 4.8.1 to 4.8.2

No special steps are required to upgrade to 4.8.2.

Upgrading the Android SDK from 4.8.0 to 4.8.1

No special steps are required to upgrade to 4.8.1.

Upgrading the Android SDK from 4.7.0 to 4.8.0

No special steps are required to upgrade to 4.8.0.

Upgrading the Android SDK from 4.6.0 to 4.7.0

The SDK now targets v2.5 of the Graph API. Please review the Graph API changelog for details.

Читайте также:  Команды для андроид студио

The GameRequestContent ‘to’ member has been deprecated and replaced with Recipients.

Upgrading the Android SDK from 4.5.1 to 4.6.0

The SDK now requires a minimum sdk of API level 15 or above.

Upgrading the Android SDK from 4.5.0 to 4.5.1

No special steps are required to upgrade to 4.5.1.

Upgrading the Android SDK from 4.4.1 to 4.5.0

No special steps are required to upgrade to 4.5.0.

Upgrading the Android SDK from 4.4.0 to 4.4.1

No special steps are required to upgrade to 4.4.1.

Upgrading the Android SDK from 4.3.0 to 4.4.0

The SDK now targets v2.4 of the Graph API. Please review the Graph API changelog for details. For example, the number of default fiends returned by Graph endpoints have been reduced and you should always explicitly ask for the fields you need.

Upgrading the Android SDK from 4.2.0 to 4.3.0

No special steps are required to upgrade to 4.3.0.

Upgrading the Android SDK from 4.1.2 to 4.2.0

The method to set the custom request code for the login button has been removed.

Upgrading the Android SDK from 4.1.1 to 4.1.2

No special steps are required to upgrade to 4.1.2.

Upgrading the Android SDK from 4.1.0 to 4.1.1

No special steps are required to upgrade to 4.1.1.

Upgrading the Android SDK from 4.0.1 to 4.1.0

There is one breaking change from 4.0.

Style attr tags are now namespaced to avoid conflicts. Apps will need to add the namespace » com_facebook_ » to their existing facebook sdk style attrs.

Upgrading the Android SDK from 4.0 to 4.0.1

No special steps are required to upgrade to 4.0.1.

Upgrading the Android SDK from 3.x to 4.x

The Facebook SDK for Android v4.0 is a major version upgrade which features:

  • Improved login programming model.
  • Improved sharing programming model, and more ways to share without needing an access token.
  • Improved error handling and error recovery mechanism.
  • The SDK now allows developers to run ProGuard across the entire project, reducing the footprint in the final APK.

Install and Setup Updates

For full instructions on install and setup for 4.x, see Getting Started Android SDK.

Set up the app ID in AndroidManifest.xml as in 3.x

If you use any native dialogs such as Share or Invite add your app name to AndroidManifest.xml :

  • LoginActivity is replaced by FacebookActivity . Add this in AndroidManifest.xml :
  • To initialize the SDK, call FacebookSdk.sdkInitialize from onCreate in Activity or Application :
  • See FacebookSdk class for other configurations you can set at app launch.

Login Updates

For more information on Login in 4.x, also see Facebook Login for Android.

Session Removed — AccessToken , LoginManager and CallbackManager classes supercede and replace functionality in the Session class.

Access Tokens — You can load AccessToken.getCurrentAccessToken with the SDK from cache or if the app is cold launched from an app bookmark. For instructions, see Facebook Login for Android, Get Current Token.

Login Button — The easiest way to add Login is to use the LoginButton in 4.x. See Facebook Login for Android, Add Facebook Login.

UserSettingsFragment class has been removed from the SDK.

LoginManager is a singleton instance, and works with the AccessToken ‘s currentAccessToken . After login the SDK sets currentAccessToken . To get additional permissions call the logInWith. methods.

LogInWith. methods always open a prompt UI if necessary. There’s no equivalent to the Session.openActiveSessionFromCache or Session.OpenActiveSession(Activity, boolean, StatusCallback) . Instead, you should check AccessToken.getCurrentAccessToken() at onCreate(), and if not null, skip login.

  • AccessToken broadcast events when it is set, unset or updated. Use the AccessTokenTracker to receive these events. See Facebook Login for Android, Track Access Tokens.
  • currentAccessToken automatically caches when the SDK sets it.
  • ProfileTracker.getCurrentProfile returns the current logged in user.
  • ProfileTracker returns events if the logged in user changes. see Facebook Login for Android, Track Current Profile.
  • CallbackManager.onActivityResult replaces Session.onActivityResult and UiLifecycleHelper.onActivityResult . See Facebook Login for Android, Register a Callback.
  • Graph API Updates

    For more information on Android and Graph API in 4.x, also see Using the Graph API, Android.

    • Request and Response classes in v3 are now called GraphRequest and GraphResponse .
    • Methods and constructors that used to take Session in v3 now take AccessToken or implicitly use AccessToken.getCurrentAccessToken if you don’t provide one.
    • Methods like newMeRequest , newMyFriendsRequest returned a typed parameter in the callback like GraphUser or List now pass in generic JSONObject and JSONArray instead.

    The old version:

    The new version

    • FacebookRequestError class has more error handling information. See Using the Graph API, Android.
    • Graph API calls now also have the ability to pass back debug information for developers during testing. You can set the LoggingBehavior.GRAPH_API_DEBUG_WARNING or LoggingBehavior.GRAPH_API_DEBUG_INFO flags in the FacebookSdk class.

    Sharing Updates

    For more information on Android and Sharing in 4.x, also see Sharing on Android.

    Источник

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