Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/222.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 调用HMS推送套件服务器API后,我的手机无法接收任何消息。SDK版本为4.0.3.300_Android_Kotlin_Push Notification_Huawei Mobile Services_Huawei Push Notification - Fatal编程技术网

Android 调用HMS推送套件服务器API后,我的手机无法接收任何消息。SDK版本为4.0.3.300

Android 调用HMS推送套件服务器API后,我的手机无法接收任何消息。SDK版本为4.0.3.300,android,kotlin,push-notification,huawei-mobile-services,huawei-push-notification,Android,Kotlin,Push Notification,Huawei Mobile Services,Huawei Push Notification,我正在使用华为的推送套件将消息推送到华为设备,SDK版本是4.0.3.300。我可以正确地获取令牌,因此我开始使用Postman调用Push Kit服务器API来推送消息。返回的消息正文显示成功,但我的设备未收到任何消息。下面是代码和我的操作。我该怎么处理这个问题? 邮递员联络地址: 职位 已发送的邮件正文: { "validate_only": true, "message": { "data": "my data", "android": {

我正在使用华为的推送套件将消息推送到华为设备,SDK版本是4.0.3.300。我可以正确地获取令牌,因此我开始使用Postman调用Push Kit服务器API来推送消息。返回的消息正文显示成功,但我的设备未收到任何消息。下面是代码和我的操作。我该怎么处理这个问题? 邮递员联络地址:

职位

已发送的邮件正文:

{
    "validate_only": true,
    "message": {
        "data": "my data",
        "android": {
            "fast_app_target": 2
        },
        "token": [
            "my token"
        ]
    }
}
答复:

{
    "code": "80000000",
    "msg": "Success",
    "requestId": "158929224618234594000607"
}
响应表示成功,但我的设备未收到任何数据消息

我已经继承了HmsMessageService并在清单文件中对其进行了配置

public class MyPushService extends HmsMessageService {
private static final String TAG = "hmspush";

@Override
public void onMessageReceived(RemoteMessage message) {
Log.i(TAG, "onMessageReceived is called");
if (message == null) {
Log.e(TAG, "Received message entity is null!");
return;
}
Log.i(TAG, "getCollapseKey: " + message.getCollapseKey()
+ "\n getData: " + message.getData()
+ "\n getFrom: " + message.getFrom()
+ "\n getTo: " + message.getTo()
+ "\n getMessageId: " + message.getMessageId()
+ "\n getSendTime: " + message.getSentTime()
+ "\n getMessageType: " + message.getMessageType()
+ "\n getTtl: " + message.getTtl());
}
}
<service
android:name=".MyPushService"
android:exported="false">
<intent-filter>
<action android:name="com.huawei.push.action.MESSAGING_EVENT" />
</intent-filter>
</service>

该问题是由不正确的消息正文引起的。在消息正文中,有一个名为validate_only的字段。根据华为开发者的描述,此字段确定消息是否为测试消息。测试消息只需要格式验证,不会推送到用户设备。 值true表示测试消息;值false表示正常消息。 由于validate_only字段的值在给定场景中为true,因此该消息是测试消息,因此设备无法接收。要解决此问题,请将validate_only的值更改为false:

{ 仅验证:false, 信息:{ 数据:我的数据, 安卓:{ 快速应用程序目标:2 }, 代币:[ 我的代币 ] }
} 该问题是由不正确的消息正文引起的。在消息正文中,有一个名为validate_only的字段。根据华为开发者的描述,此字段确定消息是否为测试消息。测试消息只需要格式验证,不会推送到用户设备。 值true表示测试消息;值false表示正常消息。 由于validate_only字段的值在给定场景中为true,因此该消息是测试消息,因此设备无法接收。要解决此问题,请将validate_only的值更改为false:

{ 仅验证:false, 信息:{ 数据:我的数据, 安卓:{ 快速应用程序目标:2 }, 代币:[ 我的代币 ] } }