Android Question Firebase Notification Problem / version 8.5

FrankDev

Active Member
Licensed User
Longtime User
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


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;
    }
 

FrankDev

Active Member
Licensed User
Longtime User
hi

seems to be running
is that really all you have to change for the notifications ????

B4X:
Sub Service_Start (StartingIntent As Intent)
 fm.HandleIntent(StartingIntent)
 Sleep(0) 'allow the MessageReceived event to be raised.
 Service.StopAutomaticForeground
 'old - > If StartingIntent.IsInitialized And fm.HandleIntent(StartingIntent) Then Return
End Sub
 
Upvote 0
Top