android - 使用 HmsMessageService(HMS 推送工具包)无法在华为设备上获取通知
问题描述
我正在使用 HMS 推送工具包来获取通知。大约 1 周前通知工作正常,但现在当我重新运行该代码时,它无法正常工作。我交叉检查了所有东西,但找不到任何东西。我正在使用的依赖项是:
implementation 'com.huawei.hms:push:5.1.1.301'
我在我的项目中也添加了 agconnect-services.json。还在清单中添加了应用程序 ID。SHA-256 密钥也可以。
接收通知的代码是:
public class HMSMessageService extends HmsMessageService {
@Override
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
}
}
我还在清单文件中添加了此服务的标签。
我也尝试过使用 HMS 工具包(android studio 中的编码助手),从那里发送通知是成功的,但我没有在应用程序上得到它。
要查看Logcat 日志,请单击此处
解决方案
可能您的设备在内部网络并且有一些安全控制,请在您的防火墙中配置推送服务器的IP地址和端口: 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
推荐阅读
- r - 使用带有 stat_summary 的 log2 传输
- arrays - 填充 UITableViewController
- c# - 向 asp net core 1.0 web 应用程序添加分页功能
- php - Websocket 棘轮
- angular - How to show the closed messages section even though there are no conversations using angular2
- machine-learning - ML 预测输入参数
- react-native - Firestore - iOS 反应原生应用程序在离线模式下工作
- kubernetes - Kubernetes 工作节点处于“NotReady”状态
- unity3d - 获得超过 1/256 的半型精度
- php - 通过PHP启动远程服务