Run command on android via firebase notification

Asked

Viewed 96 times

0

In my app I need to send a notification via firebase and run a native android command.

For example, I’m testing this by turning on the flashlight.

When I send the notification with the app opened the flashlight turns on as planned.

However when the app is closed only receive notification.

Has some way to run the same way as if with the app open and turn on the flashlight?

  • Try to insert codes you have already tested and the problems you faced, so the question does not get too wide to answer.

  • @Wictor I did not test code to run with the closed application, the test I did with the open application worked well, I want to know if it is possible to do this with the closed application

  • Qnd gets the open app notification, you treat it in your FirebaseMessagingService right? qnd it’s closed, you can do the same, but the notification information will come in your Activity input into the Intent Bundle. Something like getIntent().getExtras();.

  • @Andréozawa yes, in the method onReceiveMessage. So I have to pass the information via extras to receive in Activity? The user will have to click on the notification to execute the command? in case to turn on the flashlight

  • 1

    @reemy exactly. It’s the only way I see right now

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.