👨🏼‍💻 Improve Push Notification Delivery on non-Huawei Devices 🚀

Sinan Yılmaz
Huawei Developers
Published in
3 min readSep 9, 2022

--

Hi folks,

Today, I want to talk about a few details about the use of Push Notifications by mobile developers on non-Huawei devices.

Introduction

As you know, HMS offers us a Push Kit service for the successful sending of push notifications on Huawei devices. With Push Kit, we can interact with users quickly through this service in our apps on Huawei devices. What about non-Huawei devices?

At this point, Push Kit provides an SDK for you to aggregate a non-Huawei push channel as needed to improve the delivery rate of messages on non-Huawei devices. By the way, this feature is currently in beta. Additionally, don’t forget to include the target push platform SDK (Currently, FCM SDK is available for a maximum of version 20.0.0).

With this SDK, you can successfully send notifications to users of non-Huawei devices.

So how?

First, you need to create an app in the App Gallery. You can review this document for this process. Additionally, one thing to note here is that your app’s package name published in the third-party app store must be the same as in AppGallery Connect to avoid compilation errors.

After the application is created, we need to define the SDK’s dependency in the application-level build.gradle file.

Now we need to enable the “Configure other Android-based push” feature below, after entering the AppGallery Console, selecting our project, and coming to the settings of the Push Kit as shown below.

Push Kit Settings Page

After clicking the Enable button, a field like the one below appears and you must enter the Authentication parameters in the JSON key file of the target push platform. (For example; Firebase Console > Project Settings > Service Account > Generate new private key and copy-paste this key)

configure android-based push

Let’s take a look at the other details after these configurations are complete.

  • First, disable the automatic initialization of the Push SDK. There are 2 different methods to do this. You can find these methods here.
  • Set a country/region code for apps developed by Huawei. Skip this step for non-Huawei apps. You can use the following code in your Application class to set a country/region code.

If the country/region code is not set, the value of the region field in the agconnect-services.json file is used by default.

  • We need to initialize the push capability. For this, you can choose one of the 2 methods below.

Enabling Push Kit’s proxy initialization in AndroidManifest.xml

or

Enabling Push Kit’s proxy initialization in Application class.

  • And call the getToken method to generate the token.

From token generation, the following processes are exactly the same as the token management processes in the use of the standard Huawei Push Kit.

Conclusion

That is all. With this SDK, you can send push messages on non-Huawei devices. As you can see above, we can do this with a few small operations.

As I said, it is currently in beta version and continues to develop. For any suggestions or questions, please feel free.

References

Thanks for reading this far, don’t forget to clap if you liked it :)

--

--