3

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

Faizan Ahmad
  • 352
  • 4
  • 20

3 Answers3

1

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.

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
  • Yeah I know it, I am unable to get both Data and Notification messages. Nothing is shown on screen (not receiving any notification) – Faizan Ahmad Nov 10 '21 at 08:43
  • hi@FaizanAhmad, thanks for your feedback. Could you please leave your appId, logcat logs and token data storage locations? Let me check the info to see the problem. – zhangxaochen Nov 10 '21 at 08:48
  • 1
    AppID: 104661163 I have added a link of logcat logs in question, please have a look on it. Can you please explain about token data storage location, I am unable to understand that what are you asking. – Faizan Ahmad Nov 10 '21 at 09:22
  • hi@FaizanAhmad, sorry according to the logs provided by you, we cannot capture key information. Can you run the following command to capture a new copy of the system log? 1. Run the following command to connect to the device: `adb logcat -v time ` 2. Reproduce the issue. 3. Press Ctrl+C to complete log capture. – zhangxaochen Nov 10 '21 at 09:44
  • The token is returned [here](https://i.stack.imgur.com/f5faz.png). [Docs Link](https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/android-client-dev-0000001050042041#section11455525765) – zhangxaochen Nov 10 '21 at 09:46
  • And [here](https://i.stack.imgur.com/m5Yjw.png) are data storage location. [Docs link](https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/android-config-agc-0000001050170137#section3380135485). – zhangxaochen Nov 10 '21 at 09:48
  • 1
    Sorry, It was from backend issue. Due to some security issues, there was a check due to which We were unable to get HMS notifications. Btw Thank You so much. – Faizan Ahmad Nov 10 '21 at 09:55
1

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
flybird
  • 51
  • 2
0

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)

Faizan Ahmad
  • 352
  • 4
  • 20