Configuring HMS Push Kit

Prerequisites

  • Ensure that you have configured Push Kit on your application.
    For more information, refer to HMS Push Kit documentation.
  • Ensure that you configure MoEngage SDK for receiving push notifications

Configure your account on MoEngage

Navigate to the Settings Page `Dashboard --> Settings --> Channel --> Push --> Mobile Push --> Push Amp+` on the MoEngage Dashboard and add the Huawei Push Settings under the Push Amp+ Tab

601c695-Screenshot_2020-09-09_at_1.44.24_PM.png

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

build.gradle
dependencies {
      ...
      implementation(moengage.pushKit)
}

Alternatively, you can add the dependency directly as shown below.

Installing using Artifact Id

Add the below dependency in the app/build.gradle file.

build.gradle
dependencies {
     ...
    implementation("com.moengage:hms-pushkit:$sdkVersion")
}

replace $sdkVersion with the relevant SDK version.

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.

Kotlin Java
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

Kotlin Java
val moEngage = MoEngage.Builder(this, "XXXXXXXX")
     .configurePushKit(PushKitConfig(true))
     .build()
MoEngage.initialise(moEngage)

Add the below Service in your application's Manifest file.

AndroidManifest.xml
<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.

Version Compatibility

The hms-pushkit artifact/module is dependent on the Core SDK or moe-android-sdk artifact/module.
Based on the version of the Core SDK you are using, choose the right version of the Push Kit module.

Core SDK Version Push Kit Version
12.0.00 and above 4.0.0 and above

 

Was this article helpful?
0 out of 0 found this helpful

How can we improve this article?