library_add_check |
Prerequisites
|
SDK Installation
Installing Using Catalog
Integration using a Version Catalog is the recommended way of integration; refer to the Configure Version Catalog document to configure a catalog if not done already. Once you have configured the catalog add the dependency in the app/build.gradle file as shown below
dependencies {
...
implementation(moengage.pushKit)
}
Alternatively, you can add the dependency using Artifact ID as described in Installation using Artifact ID. However, installation using Catalog ID is the recommended approach as installing using Artifact ID may lead to version mismatch if mapped incorrectly.
Push Token Management
When using MoEngage SDK, you can either register for token and pass it on to the MoEngage SDK or simply let MoEngage SDK register for Push Token.
Token Registration Handled by Application
If your application is registering for Push Notification, use the below API to pass the Push token to the MoEngage SDK.
MoEPushKitHelper.getInstance().passPushToken(context, token)
MoEPushKitHelper.getInstance().passPushToken(context, token);
Token Registration Handled by MoEngage
By default, the MoEngage SDK does not register for push tokens. You can enable the token registration using the configurePushKit() API in the MoEngage.Builder while initializing the SDK
val moEngage = MoEngage.Builder(this, "XXXXXXXX")
.configurePushKit(PushKitConfig(true))
.build()
MoEngage.initialiseDefaultInstance(moEngage)
MoEngage moEngage = new MoEngage.Builder(this, "XXXXXXXXXX")
.configurePushKit(new PushKitConfig(true))
.build();
MoEngage.initialiseDefaultInstance(moEngage);
Add the below Service in your application's Manifest file.
<service
android:name="com.moengage.hms.pushkit.MoEPushKitMessageService"
android:exported="false">
<intent-filter>
<action android:name="com.huawei.push.action.MESSAGING_EVENT" />
</intent-filter>
</service>>
When MoEngage SDK handles push registration, it optionally provides a callback to the Application whenever a new token is registered, or the token is refreshed.
An application can get this callback by implementing the TokenAvailableListener interface and registering the listener using MoEPushKitHelper.getInstance().addTokenListener() API.
info |
Note To use Push Kit, you need to update the moe-android-sdk to 10.3.00 or above. |
Configure Your Account on MoEngage
Now you have set up Huawei Push on MoEngage SDK. Proceed to configuring Huawei Push on MoEngage dashboard.