I have an issue when using HMS push kit for sending DATA notifications to make sure onMessageReceived
is called but the problem is that for the same JSON body the notification received sometimes arrive as data and on message received is called and other times it's received as notification and is handled by the system tray this is the laravel backend code I'm using:
$body = [
"validate_only" => false,
"message" => [
"data" => json_encode($this->message),
"token" => $this->tokens
]
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://push-api.cloud.huawei.com/v1/{some_id}/messages:send',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($body),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json; charset=UTF-8',
'Authorization: Bearer ' . $this->access
)
));
$response = curl_exec($curl);
curl_close($curl);
how can I make sure it always arrives as Data?