How to handle push notification button click in flutter?

I’m using push notification buttons, and the device is receiving the notification… now I want on click of this button to run specific code, how can I achieve it in flutter?
It may be something not related to backendless, but any help would be appreciated.

@mark-piller

Hello,

The question doesn’t seem to be related to Backendless. Have you tried searching on stack overflow?

Regards,
Mark

@mark-piller
Hi, yes I’ve posted it on SO, but nobody responds, can you?
https://stackoverflow.com/questions/65685318/how-to-open-a-screen-from-backendless-push-notification
and it will be appreciated if you put in documentation steps for setup.

Hi @adel_kasno

There is no direct way to specify the flutter screen to open on notification click.
But there is a callback onMessage that will be called once the notification is received. You can put your dart code (e.g. with Navigator.push()) here:

Backendless.messaging.registerDevice(["default"], null, onMessage).then(
  (response) => print("Device has been registered!"));

void onMessage(Map<String, dynamic> args) {
  Navigator.push(...);
}

Take a look at this article, it will be very helpful:

Best Regards,
Maksym

That was helpful, thank you @Maksym_Khobotin2

1 Like