Huawei Integration
Newer phones manufactured by Huawei come equipped with Huawei Mobile Services (HMS) - a service used to deliver push instead of Google’s Firebase Cloud Messaging (FCM).
This guide will show you how to set up your Huawei Android integration in order to send push through Braze, and take advantage of all existing Braze features, including segmentation, analytics, canvas, and more!
1. Register for a Huawei Developer Account
Before getting started, you’ll need to register and set up a Huawei Developer account.
In your Huawei account, go to My Projects
> Project Settings
> App Information
, and take note of the App ID
and App secret
.
In the next step, you will enter these credentials in the Braze Dashboard which will let Braze send push on behalf of your Huawei app.
2. Create a new Huawei App in the Braze Dashboard
In the Braze Dashboard, go to Manage App Group
listed under the App Settings
navigation.
Add a new App, provide a name (i.e. My Huawei App), select Android
as the Platform, and choose Huawei (HMS)
as the Push Provider.
Once your new Braze App has been created, you will be shown an API Key
, and a section for Push Notification Settings where you will enter your Huawei credentials from the previous step.
3. Enter Huawei Credentials in the Braze Dashboard
Using the credentials from your Huawei Developer account, enter the Huawei App ID
and Huawei App Secret
within your newly created Huawei Braze App. When you’re done, save your changes.
4. Integrate the Huawei Messaging SDK into your App
Huawei has provided an Android Integration codelab detailing how to integrate the Huawei Messaging Service into your application.
After completing those steps, you will need to create a custom Huawei Message Service to obtain push tokens and forward messages to the Braze SDK.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public class CustomPushService extends HmsMessageService {
@Override
public void onNewToken(String token) {
super.onNewToken(token);
Appboy.getInstance(this.getApplicationContext()).registerAppboyPushMessages(token);
}
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
if (AppboyHuaweiPushHandler.handleHmsRemoteMessageData(this.getApplicationContext(), remoteMessage.getDataOfMap())) {
// Braze has handled the Huawei push notification
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
class CustomPushService: HmsMessageService() {
override fun onNewToken(token: String?) {
super.onNewToken(token)
Appboy.getInstance(applicationContext).registerAppboyPushMessages(token!!)
}
override fun onMessageReceived(hmsRemoteMessage: RemoteMessage?) {
super.onMessageReceived(hmsRemoteMessage)
if (AppboyHuaweiPushHandler.handleHmsRemoteMessageData(applicationContext, hmsRemoteMessage?.dataOfMap)) {
// Braze has handled the Huawei push notification
}
}
}
After adding your custom push service, add the following to your AndroidManifest.xml
.
1
2
3
4
5
6
7
<service
android:name="package.of.your.CustomPushService"
android:exported="false">
<intent-filter>
<action android:name="com.huawei.push.action.MESSAGING_EVENT" />
</intent-filter>
</service>
5. Sending Huawei Push
At this point, you’ve created a new Huawei Android app in the Braze Dashboard, configured it with your Huawei Developer credentials, and have integrated the Braze and Huawei SDKs into your app.
Next, we can test out the integration by testing out a new Push campaign in Braze.
Create a new Push Notification Campaign
In the Campaigns menu, create a new campaign, and choose Push Notification.
After you name your campaign, choose Android Push
as the Push Platform.
Next, compose your push campaign with a Title and Message.
Send a Test Push
In the Test tab, enter your user ID which you’ve set in your app using the changeUser(USER_ID_STRING)
method, and click to send the test push.
At this point, you should receive a test push notification on your Huawei (HMS) device from Braze!
Setting up Huawei Segmentation (optional)
Since your Huawei App in the Braze dashboard is built upon the Android Push platform, you have the flexibility to send push to all android users (Firebase Cloud Messaging and Huawei Mobile Services), or you can choose to segment your campaign audience to specific apps.
To send push to only Huawei apps, create a new Segment and select your Huawei App within the “Apps” section.
Of course, if you want to send the same push to all Android push providers, you can choose to not specify the app which will send to all Android apps configured within the current App Group.
Analytics
Once your campaign has been launched, you will see analytics for your campaign or canvas aggregated for Android Push. For more information on Android Push analytics and settings, see our User Guide for Push.