Hello,
since the change from b4a 7.3 to 8.5 I have a problem with the notifications.
I am sending a data message (see Source (from kmatle) ).
If the app is in the foreground everything is ok. Only 'MessageArrived' is executed.
If the app is executed in the background I now get 2 'messages'.
one in systray (without reasonable content 'notification' is not set )the other 'MessageArrived'.
(so far only 'MessageArrived' can be enabled)
If I add the 'notification' part to the data message, the message
Only displayed in systray. MessageArrived' is not executed.
regards Frank
since the change from b4a 7.3 to 8.5 I have a problem with the notifications.
I am sending a data message (see Source (from kmatle) ).
If the app is in the foreground everything is ok. Only 'MessageArrived' is executed.
If the app is executed in the background I now get 2 'messages'.
one in systray (without reasonable content 'notification' is not set )the other 'MessageArrived'.
(so far only 'MessageArrived' can be enabled)
If I add the 'notification' part to the data message, the message
Only displayed in systray. MessageArrived' is not executed.
regards Frank
B4X:
function notify ($r, $t, $m)
{
// API access key from Google API's Console
if (!defined('API_ACCESS_KEY')) define( 'API_ACCESS_KEY', 'AIzasogs94......... );
$tokenarray = array($r);
// prep the bundle
$msg = array
(
'title' => $t,
'message' => $m,
'MyKey1' => 'MyData1',
'MyKey2' => 'MyData2',
);
$fields = array
(
'registration_ids' => $tokenarray,
'data' => $msg
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, 'fcm.googleapis.com/fcm/send' );
curl_setopt( $ch,CURLOPT_POST, true );
curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
$result = curl_exec($ch );
curl_close( $ch );
return $result;
}