Installation and initialization
AppMetrica Push Unity is a plugin for the Unity3d game platform that includes support for the AppMetrica Push SDK for the Android and iOS platforms.
Before using the AppMetrica Push Unity plugin, you need to enable and initialize the AppMetrica Unity plugin version 4.0.0 or later.
Integrating the plugin
The plugin uses the External Dependency Manager for Unity to resolve dependencies.
Step 1. Download the AppMetrica Push Unity plugin.
Step 2. Add the plugin to the project — open the project in Unity Editor and import the AppMetricaPush.unitypackage plugin ( ).
Step 3. Open the Assets/AppMetricaPush/ folder and drag the AppMetrica
prefab to the project's main stage.
If the plugin is integrated this way, the AppMetricaPush script on the added prefab automatically initializes the AppMetrica Push SDK.
The added AppMetricaPush
prefab is a singleton. It isn't deleted when switching to a new Unity stage, and it deletes other objects that the AppMetricaPush
script is installed on.
Configuring the plugin
To receive push notifications, ask the user for permission. We recommend using the Mobile Notifications Unity package and request permission according to the instructions.
UnityAppController
class by using the ObjectiveC runtime. The code is in the AppMetricaPush/Plugins/iOS/YMPBridge.m file.- Configuring AndroidManifest.xml
-
Make changes in the
application
element in the AndroidManifest.xml file:<meta-data android:name="ymp_firebase_default_app_id" android:value="APP_ID"/> <meta-data android:name="ymp_gcm_default_sender_id" android:value="number:SENDER_ID"/> <meta-data android:name="ymp_firebase_default_api_key" android:value="API_KEY"/> <meta-data android:name="ymp_firebase_default_project_id" android:value="PROJECT_ID"/>
Copied to clipboardAPP_ID
— ID of the app in Firebase. You can find it in the Firebase console: go to the Project settings. In the Your application section copy the value of the application ID field.SENDER_ID
— The unique ID of the sender in Firebase. You can find it in the Firebase console: go to and copy the value of the Sender ID field.API_KEY
— App key in Firebase. You can find it in thecurrent_key
field of the google-services.json file. You can download the file in the Firebase console.PROJECT_ID
— App ID in Firebase. You can find it in theproject_id
field of the google-services.json file. You can download the file in the Firebase console.Note. If you use the AppMetrica Push SDK integration sample, change thepackage
attribute value in themanifest
element to thepackage id
of your application.There is an example of the file in the Assets/AppMetricaPush/Plugins/Android/ directory (AndroidManifest.xml).
- Configuring the location tracking
-
By default, the AppMetrica Push SDK enables device location tracking.