SDK Integration
Last updated
Was this helpful?
Last updated
Was this helpful?
Download external-dependency-manager-1.2.164.unitypackage
from the NetmeraPackages folder.
Import the package into your Unity project.
Download FirebaseMessaging.unitypackage
from the NetmeraPackages folder.
Import the package into your project.
Do not uncheck any files during import.
Download netmera-unity-1.1.4.noads.unitypackage
from the NetmeraPackages folder.
Import it into your Unity project.
Add the Netmera-Info.plist
file to your Assets folder.
Do not move it from this path.
If needed, rename the Netmera-Info.plist.example
file by removing the .example
extension. The sample file can be found
Ensure the Netmera-Info.plist
file includes the following structure:
The Step 5 is divided into two categories: Android or iOS.
google-services.json
FileTo configure Firebase messaging for your Unity application, download the google-services.json
file from the Firebase Console. Follow these steps:
Place the google-services.json
file directly in your Unity project's Assets
folder.
Note: The file path is important. Do not move it after placing it in the Assets
folder.
mainTemplate.gradle
FileUnity uses the Unity Jar Resolver to manage dependencies, and it automatically integrates the necessary Firebase components when you import the FirebaseMessaging.unitypackage
. You will need to enable custom gradle templates for the integration.
In the Unity Editor, go to Project Settings -> Publishing Settings.
Enable the following settings:
Enable Custom Main Gradle Template
Enable Custom Main Manifest
Enable Custom Gradle Properties Template
These settings will generate two gradle-related files in the Assets/Plugins/Android
folder: gradleTemplate.properties
and mainTemplate.gradle
.
Open the gradleTemplate.properties
file and append the following line:
To configure the Unity Jar Resolver, follow these steps:
In the Unity Editor, go to Assets -> External Dependency Manager -> Android Resolver -> Settings.
Apply the following recommended settings (though some are optional):
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.
These settings ensure that the Android dependencies are resolved and handled properly.
After configuring the resolver, follow these steps to ensure all dependencies are correctly imported:
In the Unity Editor, go to Assets -> External Dependency Manager -> Android Resolver -> Resolve.
After the process completes, open the mainTemplate.gradle
file and verify that the necessary libraries have been imported correctly.
In the dependencies {}
section of mainTemplate.gradle
, you should see the following libraries (version numbers may vary):
If any libraries are missing, try using Force Resolve instead of Resolve.
Note: If you encounter any duplicate class errors during the build, check for and remove duplicate dependencies.
If your Unity app exceeds the 64K method limit for a single APK, you will need to enable Multidex.
Open the mainTemplate.gradle
file and navigate to the android -> defaultConfig
section.
Add the following line to enable Multidex:
AndroidManifest.xml
FileThe AndroidManifest.xml
file is a crucial configuration file for setting up Firebase and Netmera SDK integration. Follow these steps:
Open your Unity project’s MAIN AndroidManifest.xml file, which can be found at Assets/Plugins/Android/AndroidManifest.xml
.
Add the following lines inside the <application>
tag to integrate Netmera and Firebase:
Note: If you cannot use the Netmera Application
class, you will need to manually add this line to the onCreate
method of your own Application
class:
By following these steps, you ensure that the integration between Firebase, Netmera, and Unity is correctly configured.
Navigate to Assets > Netmera > Demo > NetmeraDemoScene.
You can integrate this scene into your app to test the integration.
In your Unity scene, import the prefab located at: Assets > Netmera > Demo > Prefabs > NetmeraManager.
This prefab contains the NetmeraGameObject
script, which demonstrates SDK methods.
Do not destroy this object while switching between Unity scenes. It should persist throughout the app.
In the Awake()
method of your scene, call:
The loggingEnabled
boolean controls whether logging is enabled in the Netmera SDK. This can be set in the Unity editor to toggle logging functionality.
In the Awake
method, the following actions are performed:
Stack trace logging for regular log messages is disabled.
The NetmeraGameObject
is set to persist across scene loads using DontDestroyOnLoad
.
The Test_Init
method is called to initialize the Netmera SDK.
Test_Init
The Test_Init
method initializes the Netmera SDK. If the NetmeraCore
instance is available, logging is configured based on the loggingEnabled
flag, and the SDK is initialized.
Sending an Event
The following method sends an event to the Netmera SDK, with sample data provided for event category and count.
This method creates a NetmeraUser
object and updates the user's birthday and city information.
The Test_FetchInbox
method fetches inbox items, with a filter for "read or unread" push notifications.
This method fetches the next page of inbox items.
The Test_Destroy
method destroys the current Netmera SDK instance.
This method allows for enabling or disabling popup presentations for push notifications.
This method retrieves the count of push notifications based on their status (read/unread).
The Test_ChangeInboxItemStatuses
method allows for changing the status of specific inbox items.
The Test_RequestPermissionsForLocation
method requests permissions to access the user’s location.
This method changes the status of all inbox items to "deleted."
The class implements several callback methods for handling events related to push notifications and inbox operations. Each callback is currently a placeholder, but you can add custom logic to process the events as needed.
Push Notifications:
OnPushRegister
: Triggered when the device registers for push notifications.
OnPushReceive
: Triggered when a push notification is received.
OnPushOpen
: Triggered when a push notification is opened by the user.
OnPushDismiss
: Triggered when a push notification is dismissed.
OnPushButtonClicked
: Triggered when a button in a push notification is clicked.
Inbox Operations:
OnInboxFetchSuccess
: Triggered when inbox items are successfully fetched.
OnInboxFetchFail
: Triggered when there is a failure to fetch inbox items.
OnInboxNextPageFetchSuccess
: Triggered when the next page of inbox items is successfully fetched.
OnInboxNextPageFetchFail
: Triggered when there is a failure to fetch the next page of inbox items.
OnInboxStatusChangeSuccess
: Triggered when the status of inbox items is successfully changed.
OnInboxStatusChangeFail
: Triggered when there is a failure to change the status of inbox items.
OnInboxStatusCount
: Triggered when the count of inbox items with a specific status is retrieved.
Download the file from the .
Note: If your minSDK
version is below 21, additional steps are required. You can find more details on enabling Multidex .
Download the GoogleService-Info.plist file from the Firebase Console. You can find detailed instructions .