Unable to get Notifications on Huawei devices with HmsMessageService (HMS push kit)

Viewed 528

I am using HMS push kit to get notification. Notifications were working fine about 1 week ago, but now when I re run that code, it is not working. I cross checked all the things but unable to find anything. Dependency which I am using is:

implementation 'com.huawei.hms:push:5.1.1.301'

I have added agconnect-services.json too in my project. Also added app id in manifest. SHA-256 key is also fine.

Code to receive notifications is:

public class HMSMessageService extends HmsMessageService {

@Override
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
    
    }
}

I have also added the tag of this service in manifest file.

I also tried with HMS toolkit (Coding assistant in android studio), sending notification from there is successful but I am not getting it on app.

enter image description here

To view Logcat Logs, click here

3 Answers

Based on the content provided by you, the following method is used to receive data messages instead of notification messages. And notification messages are displayed on the device.

public class HMSMessageService extends HmsMessageService {

@Override
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
    
    }
}

If still unable to get notifications, you could provide information such as logcat logs and token data storage locations, according this we can analyze this issue and try to help.

maybe your device is in internal network and have some security control, pls configure push server's ip address and port in your firewall: https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/restrictions-0000001050040064#section10881161131412

If a firewall is configured on the network of your app users, ensure that the following port numbers and IP addresses are enabled to allow traffic, so that your message delivery rate will not be affected:

Port numbers:

443
5223
IP addresses:

49.4.0.0/20
80.158.0.0/16
114.119.0.0/20
121.36.0.0/20
159.138.0.0/20
160.44.0.0/16

It was due to some backend issues. Due to security reasons there were some checks (IP was blocked) due to which I was unable to get notifications. (But it is strange that due to that backend checks, only HMS notifications were blocked, not firebase notifications)

Related