Unity SDK Integration
Step 1. Importing Unity Jar Resolver
Download external-dependency-manager-1.2.164.unitypackage
from NetmeraPackages folder and import it into your project.
Step 2. Importing Firebase Messaging
Download FirebaseMessaging.unitypackage
from NetmeraPackages folder and import it into your project (Please do not uncheck any file while importing).
Step 3. Importing Netmera
Download netmera-unity-1.1.4.noads.unitypackage
from NetmeraPackages folder and import it into your project.
Step 3.1 Adding Netmera-Info.plist file
Add Netmera-Info.plist file into your Unity application's Assets folder. (Note: Path is important. Do not move it anywhere.) You can find example Netmera-Info.plist.example file here. (Don't forget to remove .example extension at the end of the file name.)
Your Netmera-Info.plist file should look like this:
The following steps are separated into two as iOS and Android,
Step 3.2 Adding a google-services.json file
Download google-services.json file from Firebase console panel( More info at: https://firebase.google.com/docs/cloud-messaging/android/client#add_a_firebase_configuration_file ) Put this file into your Unity application's Assets folder. (Note: Path is important. Do not move it anywhere.)
Step 3.3. Usage of a custom mainTemplate.gradle
file.
mainTemplate.gradle
file.Unity Jar Resolver will be used for integration. You already included it by importing FirebaseMessaging.unitypackage.
Click Project Settings -> Publishing Settings -> Enable Custom Main Gradle Template, Custom Main Manifest and Custom Gradle Properties Template.
There should be two gradle related files gradleTemplate.properties
and mainTemplate.gradle
inside the folder Assets->Plugins->Android.
Open gradleTemplate.properties
file, and append this line android.useAndroidX=true
Step 3.4. Jar Resolver Settings
Inside Unity Editor's top navigation panel, click Assets -> External Dependency Manager -> Android Resolver -> Settings.
The below settings are recommended but not a must. The remaining settings are up to you.
Uncheck 'Enable Auto Resolution' Uncheck 'Enable Resolution on Build' Check 'Install Android Packages' Check 'Explode AARs' Check 'Patch AndroidManifest.xml' Check 'Patch mainTemplate.gradle' Check 'Patch gradleTemplate.properties' Check 'Use Jetifier'
Step 3.5. Jar Resolver Resolve Process
Inside Unity Editor's top navigation panel, click Assets -> External Dependency Manager -> Android Resolver -> Resolve.
Open mainTemplate.gradle
file and check that whether libraries are imported correctly.
Inside dependencies{}
section of this file, you should at least see the following libraries (version numbers would change).
If they are not included, you can try with 'Force Resolve' rather than 'Resolve'.
Note: While building your app, If you get duplicate class error, please check the dependencies and remove the duplicate one.
Step 3.6. Enable Multidex
Open mainTemplate.gradle
file, then go to Android -> defaultConfig section.
Add a new item as multiDexEnabled true .
If your minSDK version is below 21, you may need additional steps to perform -> https://appmediation.com/unity-enable-multidex/ .
Step 3.7. Editing your AndroidManifest.xml file
Open your Unity project's MAIN AndroidManifest.xml file (located at Assets>Plugins>Android>AndroidManifest.xml) and add the following ones inside application tag. Note: It is important to edit your Main AndroidManifest.xml file since there may be multiple AndroidManifest files. Please edit this file: Assets>Plugins>Android>AndroidManifest.xml
Use Netmera SDK's application class and add required meta-data tags:
Note: If using Netmera's Application class is not possible for you, you need to add this line to your own Application class' onCreate method rather than referencing to NetmeraCustomApp.
Step 4. Demo Scene
We prepared a sample Unity Scene to show the capabilities. Open
Assets->Netmera->Demo->NetmeraDemoScene.
You can include this scene to your app in order to test your integration.
Step 5. Adding Prefab to your first Unity Scene
In your first Unity Scene, import the prefab at:
Assets->Netmera->Demo->Prefabs-> NetmeraManager.
This prefab contains the NetmeraGameObject script which shows the usage of all methods of the SDK. Please do not destroy this object while swapping your Unity Scenes. It should not be destroyed.
You can create a similar implementation or use Netmera SDK by editing this file based on your use-cases. Please call NetmeraCore.Instance.Init(this); method before calling any other methods. Ideal place is Awake() method.
NetmeraGameObject content:
Last updated