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.

Tip: More information about Synerise.Builder is available in the “Configuration” section of this article.

Implementing Huawei notifications in applications

  1. 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>

  2. In onRegisterForPush, pass the huaweiToken using the Client.registerForPush(token, pushAgreement) method.

  3. 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")
    }
    

  4. Pass the incoming push notification payload to the Injector in your HmsMessageService 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)
            }
        }
       

Tip: For more information, visit Huawei Codelab.

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.

In order to implement links and deep links, refer to this instruction.

Configuring notification encryption

Instructions for encrypting push notifications are available here.

😕

We are sorry to hear that

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

😉

Awesome!

Thank you for helping improve out documentation. If you need help or have any questions, please consider contacting support.

Close modal icon Placeholder alt for modal to satisfy link checker