Skip to content
Advertisement

Android Java Notification Not Displaying

This is my first time working with Notifications and I can’t seem to figure out the issue.

What I am Trying To do:

In short, I have a service that checks for a variable in a firebase document, if it’s true, show a notification. And before you say it, I can’t use Cloud Functions in this scenario. I’ll explain, everything in detail, so bear with me, thanks.

What’s Happening

Based on my logs, I have an idea of what’s happening, let me summarize it in a few short points.

  1. The service is running every 30 minutes, By Job Scheduler. That is the “Job started” log.
  2. It calls the check bookings function that checks for the above mentioned variable, that is the “Checkbookings”, “true”, and “false” logs.
  3. The final log is “Add notification” which is in the addNotifcation function where I build the notification. This log appears after the “true” log.

The issue

Add notification is called but the notification is not shown. Logs And Emulator

I will paste the Logs, relevant code below any input or suggestion will be appreciated, thanks

Logs

JavaScript

Code

JavaScript

If you need any more details, let me know

Advertisement

Answer

When you want to create a notification, you need to first create a channel for it. Here is an example:

JavaScript

After this you can call add notification:

JavaScript

This should work

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement