Unity facebook android sdk

Интеграция Facebook SDK в Unity 3D

Facebook SDK используется для сбора данных о поведении игроков внутри мобильных приложений. С помощью него можно узнавать различные игровые показатели, а так же использовать для закупки и отслеживания трафика, через рекламную сеть Фейсбук. В этом уроке расскажу как интегрировать Facebook SDK аналитику в ваш Unity проект.

Как встроить Facebook SDK в Unity 3D

Регистрация и создание приложения

  • Для начала заходим на сайт фейсбук разработчика https://developers.facebook.com и регистрируемся.
  • Заходим в «Мои приложения» и создаем новое, нажав на зелёную кнопку «Создать приложение».
  • Тут потребуется загрузить иконку(размер 1024 на 1024 пикселей и не содержащую альфа канала).
  • Выбрать жанр и категорию игры.
  • Указать адрес политики конфиденциальности, её можно создать с помощью генератора политики конфиденциальности.
  • Выбрать платформу — Android или iOS. Затем вводим bundle id приложения.
  • Название класса и ключевые хэш-адреса для андроид вводим потом, после добавления SDK они сгенерируются в Unity. Их нужно будет скопировать.
  • Нажимаем «Сохранить изменения»

Интеграция в Unity 3D

  • Приложение создано, теперь скачаем sdk для Unity. Возвращаемся в «Мои приложения» и заходим Документы>Unity SDK>Download The SDK
  • Дожидаемся окончания загрузки и импортируем его в проект на Unity.
  • После завершения импорта заходим в верхнее меню Facebook>Edit Settings и в строке «App name» вводим название игры.
  • Далее надо ввести facebook app id, чтобы его найти, надо вернутmся в аккаунт разработчика, выбрать нужное приложение и в верхней части экрана скопировать его нажав мышкой. Копируем и вставляем в Unity.
  • Далее можете скопировать Classs Name и Keys Hash из Unity и вставить в настройках фб приложения.
  • Затем нажимаем «Regenerate Android Manifest» и «Build SDK Package».
  • Плагин интегрирован и надо создать скрипт который, будет при старте нашей игры инициализировать sdk. Заходим в официальную инструкцию фейсбук developers.facebook.com/docs/unity/examples и копируем данный код инициализации:
  • Сохраняем скрипт и вешаем его на новый GameObject на сцене.
  • Теперь можете сделать сборку под android File>Build Settings>Build или ios и запустить на телефоне.
  • Зайти в аккаунт разработчика Фейсбук и в верхнем углу нажать переключатель «Опубликовано» когда приложение будет готово и в правом меню перейти в аналитику.

В Аналитике будут отображаться все пользователи, которые были у вас за определенный период (день, неделя, месяц и тд). Также можно отслеживать, какие события были совершены ими. Надеюсь эта статья была полезна, спасибо!

Источник

Facebook SDK for Unity

Requires Unity 5.4 and up.

Get Started
Basic guide for Unity SDK

SDK Reference Docs
API Reference Docs

View Source
View Source On Github

The Unity engine and ecosystem gives developers a world class technology platform from which they can build games that work seamlessly across multiple platforms quickly and effectively.

The Facebook SDK for Unity complements Unity Technologies’ cross-platform support, providing a pure-Unity write-once, run-everywhere experience across the key gaming platforms of WebGL, Unity Web Player, Android and iOS. By maintaing a single codebase, you’ll be able to deploy socially integrated gaming experiences to your players, regardless of platform.

Читайте также:  Ненадежный или недействительный сертификат при настройке почты android

The Facebook SDK for Unity provides a comprehensive collection of Facebook’s social features, giving players of your Unity game the ability to share content with their friends and allowing you to create a personal, social gaming experience. In addition to providing a base set of features that are invoked consistently across platforms, the SDK also offers support for Facebook features that are unique to a particular platform (e.g. payments on the Web or App Invites on mobile). This will allow you to keep your code clean, using a simple, consistent model for everything your game can do on Facebook.

In Unity SDK

Login

People can easily sign in to your game with their Facebook Login.

Share

People can share content with their friends. They can also share Custom Stories with Open Graph.

Game Invites

People can send invites to friends from your game.

App Events

Understand people’s actions in your game and measure the effectiveness of your Mobile App Ads.

Graph API

Get data in and out of Facebook’s social graph. Query data, post stories, upload photos and do other tasks.

Drive installs with Mobile App Install Ads. Increase engagement with Mobile App Engagement Ads. Find your target audience with Custom Audiences for Mobile Apps. Monetize in your game with Audience Network.

Link to a context in your game.

Audience Network

Monetize your mobile property with Facebook ads.

Other Resources

Porting From Mobile to Canvas

Guide for mobile developers thinking about bringing their games to Facebook Canvas.

Terms of Use

Terms of use for Facebook’s open source SDKs

Privacy Policy

Privacy policy for Facebook’s open source SDKs

Источник

Getting Started with the Facebook Unity SDK

This guide provides step-by-step instructions to implement the Facebook Unity SDK.

The Facebook Unity SDK works with Unity 5.0 and above.

Before You Start

You will need the following:

Get Your Facebook App ID

In your app dashboard under Settings > Basic, copy your App ID.

Add the SDK to your Unity project

Step 1: Create a new project in the Unity Editor.

Step 2: Download the latest Facebook SDK. Unzip this package after downloading. The code for this sample project will be included.

Step 3: In the Unity editor, select Assets > Import Package > Custom Package… Navigate to the directory where you downloaded the Facebook for Unity SDK and select FacebookSDK.unitypackage . Note: You will need to remove previously integrated Facebook SDK packages before importing a newer version.

Step 4: Import all assets in the package.

Step 5: Save your project. A post-build script will add a Facebook menu item to the Unity editor. If you don’t see this, check your build for compilation errors and try building again.

Step 6: In the Unity editor, select Facebook > Edit Settings.

In the Inspector FacebookSettings, paste in your Facebook App ID.

Run the sample project

Step 1: In the Project panel, under Assets > FacebookSDK, you will find all the files for the Facebook Unity SDK. Open the folder titled Examples. Double click on the MainMenu scene to open the sample project menu.

Step 2: In the Unity editor, select File >Build Settings.

Select all the Unity Scenes in the Examples folder and drag them over to the Build Settings panel. Drop them in Scenes In Build. Drag the MainMenu scene to the 0 position, the first position in the list.

Step 3: Enter Play mode to run our example code for a simple demo of the Facebook SDK functionality.

Читайте также:  Android content context activity

Note: The Unity editor environment offers limited functionality, and all the functions are stubbed. It is safe to ignore any warnings or errors regarding the inability of the example game to reach Facebook.

Next Steps

After the basic configuration of the Unity SDK refer to the guides below to continue with platform specific configurations.

Источник

Unity facebook android sdk

Facebook SDK for Unity

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

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

  1. Check-out the tutorials available online at https://developers.facebook.com/docs/unity/getting-started
  2. Start coding! Visit https://developers.facebook.com/docs/unity/ for tutorials and reference documentation.
  • Login — https://developers.facebook.com/docs/facebook-login
  • Sharing — https://developers.facebook.com/docs/sharing
  • App Links — https://developers.facebook.com/docs/applinks
  • Graph API — https://developers.facebook.com/docs/graph-api
  • Analytics for Apps — https://developers.facebook.com/docs/analytics

You can also join the Facebook Developers Group on Facebook (https://www.facebook.com/groups/fbdevelopers/) or ask questions on Stack Overflow (http://facebook.stackoverflow.com)

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

  • Follow the instructions in the CONTRIBUTING.mdown.
  • Submit your pull request to the dev branch. This allows us to merge your change into our internal master and then push out the change in the next release.

SETUP DEVELOPMENT ENVIRONTMENT IN MAC

Since Unity decided to change the way in which each of the versions was installed in the Mac file system, Unity Hub, and also due to changes in the distribution of implementations in the DLL from version 2019, it is necessary to solve the dependencies references in the project depending on the installed version. -For this, this process has been automated through a script ./configure.sh that is in the root of the project. You should run this script before opening the Facebook.sln project.

You can use an interactive mode, this mode tries to find the unity versions installed on your system and will ask you which version to use.

Or you can input a version directly as parameter

Usage: ./configure.sh or ./configure.sh [Unity version] Unity version: Exactly full definition as it appears. Ex: 2017.4.40f1, 2018.4.36f1, 2021.1.17f1

BUILDING THE SDK

Except as otherwise noted, the Facebook SDK for Unity is licensed under the Facebook Platform License (https://github.com/facebook/facebook-sdk-for-unity/blob/master/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.

Читайте также:  Android spinner select selected item

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 Unity you agree to these terms.

Источник

Getting Started with the Facebook SDK for Unity on Android

Note: This guide is organized to follow after the shared setup steps for the Facebook SDK for Unity detailed in the Getting Stared guide. If you have not yet completed these steps please do so first.

This document provides an follow up step-by-step guide to get started with the Facebook SDK for Unity on Android. We will build and deploy the sample Unity app bundled with the Unity SDK to allow you to get working on a Facebook integration quickly and effectively. If you’re more comfortable working on iOS or Web, you can switch to the Getting Started guides for those platforms.

Configuring your app for Android

Step 1: Switch to the Android Platform

Go to the Unity Editor. From the menu, choose ‘File’, ‘Build Settings…’ In the Build Settings dialog, under ‘Platform’, select ‘Android’ as the target and click ‘Switch Platform’. Ensure the sample project scenes have been added to the ‘Scenes in Build’ as previously described here.

Step 2: Set Android Miniimum API Level

Click on Player Settings and make sure the android Minimum API level is set to «Android 4.0.3 ‘Ice Cream Sandwich’ (API level 15)» or higher.

Step 3: Configure Bundle ID and Key Hash

With the Build Settings dialog still open, click ‘Player Settings. ‘ Then, in the Inspector pane go to ‘Settings for Android’, then ‘Other Settings’. Fill in the ‘Bundle Identifier’ field with a valid bundle identifier, usually formed using your company name and product name. Save your project.

Now select ‘Edit Settings’ from the ‘Facebook’ menu.

Find and note the value of the ‘Debug Android Key Hash’ in the ‘Android Build Facebook Settings’ panel. Also note the value of the ‘Class Name’.

Now, let’s add the Bundle ID, Key Hash, and Class Name to your app’s Facebook settings. Go to the ‘Android’ pane in the Basic tab of your app’s ‘Settings’ page, and fill in the ‘Bundle ID’, ‘Key Hashes’ , and ‘Class Name’ fields. Now save your changes.

Now, back in the Unity Editor, click the ‘Build’ button. When prompted for an output directory name, call it unity_android . You can choose to export an APK file directly, which you can install on a test device, or to export a project file to be opened in your Android IDE.

Now you’re up and running on Android. Congratulations!

Next steps

Feel free to explore the sample app to try out the various features of the SDK. Start by clicking the FB.Init button at the top of the sample, which will enable the other features of the sample. As a next step, modify the code included in the sample and add it to your game project; this will get your Facebook integration off to a flying start.

For more details on integrating the Facebook SDK into your Unity game, check out the SDK reference and SDK Examples. And if you’d like to see how easy it is to deploy to Facebook Canvas and iOS, check out their respective Getting Started guides.

Источник

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