I'm using Huawei's Push Kit to push messages to Huawei devices, and the SDK version is 4.0.3.300. I can obtain the token correctly, so I start to use Postman to call the Push Kit server API for pushing messages. The returned message body shows success, but my device didn't receive any message. The following are the code and my operations. What shall I do to handle this problem? Postman call address:
POST https://push-api.cloud.huawei.com/v1/[myappid]/messages:send
Message body sent:
{
"validate_only": true,
"message": {
"data": "my data",
"android": {
"fast_app_target": 2
},
"token": [
"my token"
]
}
}
Response:
{
"code": "80000000",
"msg": "Success",
"requestId": "158929224618234594000607"
}
The response indicates success, but my device did not receive any data message.
I've already inherited HmsMessageService and configure it in the manifest file.
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>