Huawei integration for Android
Enable integration in the Synerise platform
Full instructions are available at “Huawei integration”.
Configuration
In order to integrate Huawei Mobile Services with Synerise, you must add .mesaggingServiceType(MessagingServiceType)
to your Synerise.Builder
.
We recommend passing MessagingServiceType.HMS
as an argument when you build the app for AppGallery.
Synerise.Builder
is available in the “Configuration” section of this article.Implementing Huawei notifications in applications
-
Register your service in the AndroidManifest:
<application android:name=".App" android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> ... <service android:name=".service.MyPushService" android:exported="false"> <intent-filter> <action android:name="com.huawei.push.action.MESSAGING_EVENT" /> </intent-filter> </service> </application>
-
In
onRegisterForPush
, pass the huaweiToken using theClient.registerForPush(token, pushAgreement)
method. -
Add the Huawei registration method:
override fun onNewToken(p0: String?, p1: Bundle?) { super.onNewToken(p0, p1) val call = Client.registerForPush(p0!!, true) call.execute( { Log.i(TAG, "Register for Push succeed: $p0") } ) { apiError: Any? -> Log.i(TAG, "Register for push failed:" + apiError.toString()) } Log.i(TAG, p0!!) Log.i(TAG, "receive token: $p0") }
-
Pass the incoming push notification payload to the
Injector
in yourHmsMessageService
implementation:val scope = CoroutineScope(Dispatchers.IO + SupervisorJob()) override fun onMessageReceived(p0: RemoteMessage?) { super.onMessageReceived(p0) val data: Map<String, String> = p0!!.dataOfMap scope.launch { Injector.handlePushPayload(data) } }
Huawei Limitations
Banner campaign will only be displayed when your app is in the foreground. When it is in the background, a push notification is not displayed.
Links and Deep Links
In order to implement links and deep links, refer to this instruction.
Configuring notification encryption
Instructions for encrypting push notifications are available here.