0

i am sending a notification from my server using FCM to my users that contain both a data and notification type payload.

based on the docs:

Messages with both notification and data payload, both background and foreground. In this case, the notification is delivered to the device’s system tray, and the data payload is delivered in the extras of the intent of your launcher Activity.

everything works fine, the notification shows up on the system tray now i would like to show that notification for about 20 seconds and then let it disappear from tray if the user did not click or do anything. (so methods with a handler wont work since the user is not clicking)

Am really not sure how to go about this, can someone please help!

Abdeen
  • 922
  • 9
  • 30
  • that wont work, since the user is not clicking on the notification and no activity is launching. or am i wrong? – Abdeen May 14 '18 at 04:21
  • I think your only option is to send a data-only message and generate the notification yourself in `onMessageReceived()`. When you build the notification, use `NotificationCompat.Builder.setTimeoutAfter()` for automatic clearing. – Bob Snyder May 14 '18 at 13:33
  • hey bob, thanks for your feedback. i tried to implement that but i cant seem to get it right, can you please provide a code example for reference or something – Abdeen May 14 '18 at 14:38
  • There is example code here (scroll down about 7 screens): https://medium.com/@nileshsingh/how-to-add-push-notification-capability-to-your-android-app-a3cac745e56e – Bob Snyder May 14 '18 at 14:52

0 Answers0