Enabling HMS Push Kit support
Setup project in the HMS console and integrate it with your app.
Add Huawei push kit dependency to your app’s gradle file.
implementation 'com.huawei.hms:push:6.3.0.304'
Enable HCM handling for SDK.
public class MyApp extends Application {
@Override
public void onCreate() {
ProxiCloudSdk.create(getApplicationContext(), "API_KEY"); //init SDK as usual
ProxiCloudSdk.getInstance().enableCloudMessaging();
}
}
For SDK to access notification data you need to extend HmsMessageService. We provide default implementation, but it has to be registered in the application’s manifest. Do it only if you don’t already extend this class as only one service will receive messages.
<service
android:name="cloud.proxi.sdk.hcm.ProxiCloudHcmService"
android:exported="false">
<intent-filter>
<action android:name="com.huawei.push.action.MESSAGING_EVENT" />
</intent-filter>
</service>
If you already have your own implementation, pass received message to the SDK. It will recognize which messages should be handled.
public class MyHmsMessageService extends HmsMessageService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
ProxiCloudSdk.getInstance().getHcmManager().handleMessage(remoteMessage);
}
}