Huawei Integration
Last updated
Was this helpful?
Last updated
Was this helpful?
Netmera uses Huawei Push Message to deliver push notifications to Android devices.
To enable this, you must set up and configure a project on > Huawei Developers Console.
Follow Huawei's official documentation to integrate HMS Core your project using the links below:
Navigate to the Huawei Developers Console
Enable the Push Kit service for your application.
Generate your app's SHA-256 fingerprint using your keytool.
Add this fingerprint to your app configuration in the Huawei Console under the App Information section.
Download the agconnect-services.json
file from the Huawei Developers Console.
Place this file in the root of your app’s folder within your project directory.
Upon completing the configuration, you will obtain:
App Secret Key (Client ID generated in the Huawei project)
App_ID (Client Secret Key generated for your app)
Add these values to the Netmera Dashboard:
Go to Developers > Push Backends > Huawei.
Enter the App Secret Key and App_ID.
Use App_ID for Initialization:
During client-side initialization in your application, ensure that you use the App_ID.
App_ID: Corresponds to the Client ID generated in the Huawei project.
App Secret Key: Corresponds to the Client Secret Key generated for your app.
The Netmera Android SDK is available via the Maven repository. Follow these steps to integrate it into your project.
Modify Your build.gradle
File
Update your project's build.gradle
file as follows:
Add the Netmera dependencies in the dependencies
block:
At the very end of your app's build.gradle
file, apply the Huawei plugin:
Important Note for Obfuscation:
Netmera SDK seamlessly integrates with obfuscated code, you don't need to add any specific rules.
Add the following initialization code inside the onCreate()
method of your android.app.Application
class.
If Application Class is Not Already Present:
Create an Application Class
If your project doesn't yet have an Application
class, create one and include the initialization code as shown below.
Update AndroidManifest.xml
In the AndroidManifest.xml
, add your Application
class by specifying android:name
in the <application>
tag.
Important Notes on API Key:
Do not use the API key from a test panel in production.
Each panel has a unique API key, and using the wrong one can result in data misdirection or errors.
To obtain your SDK API Key:
Go to the Netmera Panel.
Navigate to Developer > API > SDK API Key.
Copy your SDK API Key from this section.
Enabling Logging
To enable logging for debugging purposes, include the following line in the onCreate()
method
Netmera allows displaying pop-up notifications within the app using an internal activity class. However, this feature is disabled by default to prevent disrupting your app's flow at launch. To enable pop-up notification presentations,
Place the following code in your main activity after it has started:
Important Note
Do not include this code in your splash activity if your app uses one. This ensures an app launch without interruptions.
If you have implemented your own Huawei Mobile Services (HMS) integration, you can still use Netmera's push notifications. Implement the following steps in your class that extends HMSMessageService
1. Receive and Process Push Messages
Override the onMessageReceived
method to handle Netmera push messages:
2. Handle Token Renewal
Override the onNewToken
method to forward the token to Netmera:
For successful push message delivery, complete all steps in the Huawei Message Receipt Guide below. This ensures your configuration aligns with Huawei's requirements for sending push notifications.
Complete the steps in Huawei Message Receipt to send push messages.
Huawei SDK integration is complete, and your devices are now ready to receive the following types of push notifications from the Netmera Dashboard:
Standard Push Notifications
Interactive Push Notifications
Widgets
Push Notifications with Deeplinks