Huawei Push Kit SDK Integration
Last updated
Last updated
Quick Steps Guidelines
Step 1: Create A Huawei Push Message Configuration
Create and configure a project on the Huawei Developers Console.
Step 2: Integrate SDK
Add the configurations in the step to your build.gradle file.
Step 3: Initialize Netmera
Add the code to the onCreate() method of the class that extends android.app.Application.
Step 4: Enable Pop-up Presentation
Enable pop-up notifications
Step 5: Huawei Message Receipt
For the final step, make sure to complete the steps in Huawei / Message Receipt.
Huawei SDK integration completed
Netmera utilizes Huawei Push Message to deliver push messages to Android devices. Therefore, it's essential to create and configure a project on the Huawei Developers Console. Follow these steps for Huawei Push Kit Configuration.
Begin by following Huawei's guides for setting up your application using the following links:
Enable PushKit first within the Huawei panel.
Add the SHA256 fingerprint value of your application to the Huawei Console.
Download the agconnect-services.json
file and place it in your app's folder.
After completing the configuration, you will obtain the values of the App Secret Key and App_ID for your project. These values need to be added to the Netmera Dashboard under Developers > Push Backends > Huawei. Additionally, the App_ID should be used during client initialization.
The App ID and App Secret Key:
The app ID and app secret key information corresponds to the client ID and client secret key generated under the project for the app.
The Netmera Android SDK is available through the Maven repository. To integrate it into your project, follow these steps:
Modify your build.gradle file:
Add the following configurations to your build.gradle
file. AndroidManifest and other resource configurations are automatically handled by the Android Gradle build tool.
Add Netmera dependency:
In your build.gradle (:app)
file, include the Netmera dependency within the dependencies
section:
Important Note for Obfuscation:
If you choose to obfuscate your code, you don't need to add any specific rules. Netmera's SDK seamlessly integrates with your obfuscated code.
To initialize Netmera, add the following code to the onCreate()
method of the class that extends android.app.Application
. If you don't have such a class, create it and add it to your AndroidManifest file using the android:name
attribute within the application tag.
Please make sure you get the API key value from the relevant panel
YOUR_SDK_API_KEY: You can get the api key from Developers > API > SDK API Key from your web panel.
Enabling Logging:
You can also enable logging by adding the following line of code to the onCreate()
method of your class that extends android.app.Application
:
Pop-up notifications are automatically displayed within the app through an internal activity class in Netmera. However, to prevent disruption to your app's flow at launch, this feature is disabled by default. It is essential to call the following method in your main activity, ensuring not to add it to a splash activity if you have one:
To enable pop-up notifications, follow these steps:
In your main activity, after it has started, add the following code:
Please ensure that you do not include this code in a splash activity if your app has one.
If you have your own Huawei Mobile Services (HMS) integration and wish to integrate Netmera's push notifications, consider implementing the onNetmeraPushMessageReceived
method in your onMessageReceived
function. Additionally, when the token is renewed, ensure to call this method to forward it to Netmera(Netmera.onNetmeraNewToken(token)
Here's an example of implementing this in your class that extends HMSMessageService
:
To ensure the successful sending of push messages, please follow the steps outlined in the "Huawei Message Receipt" guide. Complete all the necessary steps as described to ensure your push messages are sent effectively.
Huawei Message Receipt:
Make sure to complete the steps in Huawei / Message Receipt to send push messages.
Huawei SDK integration has been successfully completed, and your devices are now ready to receive the following types of push notifications sent via the Netmera Dashboard:
Standard Push Notifications
Interactive Push Notifications (If you've configured and published them using the Dashboard)
Push Notifications with Web View Content
Push Notifications with Deeplinks (If your application supports URL Scheme-based deeplinks and you've configured the application's URL Scheme in the Dashboard.)