-
Notifications
You must be signed in to change notification settings - Fork 409
How set action on Closed App #13
Comments
Hi, For Firebase message notification does not support special notifications, use a data message because it call every time onMessageReceived. $dataBuilder = new PayloadDataBuilder();
$dataBuilder->addData(['a_data' => 'my_data']); maybe this thread can be help you : http://stackoverflow.com/questions/38504078/firebase-expandable-notification-show-image-when-app-is-in-background. I hope that will help you . Please give me a feedback if that solve or not your issue. Best regards Nicolas |
Hello, thankyou for your reply! But my problem persist.
I have this function, and when the app is open pass on onMessageReceived corretly, but when I close my app the onMessageReceived is not executed. am I doing something wrong? |
Hello, Try to remove the notification payload of your message like bellow: public function alert($text = null, $token, $action=null)
{
$optionBuiler = new OptionsBuilder();
$optionBuiler->setTimeToLive(60*20);
$dataBuilder = new PayloadDataBuilder();
$dataBuilder->addData(['a_data' => 'my_data']);
$data = $dataBuilder->build();
$option = $optionBuiler->build();
FCM::sendTo($token, $option, null, $data);
} because when notification is present on the payload, android will handle the message and show it without passing in onMessageReceived when app is in background. From FCM documentation :Messages with both notification and data payloads App behavior when receiving messages that include both notification and data payloads depends on whether the app is in the background or the foreground—essentially, whether or not it is active at the time of receipt. When in the background, apps receive the notification payload in the notification tray, and only handle the data payload when the user taps on the notification. {
"to" : "APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx...",
"notification" : {
"body" : "great match!",
"title" : "Portugal vs. Denmark",
"icon" : "myicon"
},
"data" : {
"Nick" : "Mario",
"Room" : "PortugalVSDenmark"
}
} Please could you test it and give me a feedback ? |
Yes! it Work! |
Hello,
I would like to ask if I can set equivalent of .addAction() and .setStyle() of notification or how use app notification builder on closed app.
Because my problem is that when my app is closed does not execute code in onMessageReceived and I can't notification.setStyle or .addAction().
thank you for share!
The text was updated successfully, but these errors were encountered: