Search code examples
androidfirebase-cloud-messagingheads-up-notifications

Show Heads-up notification when app is background


I want to appear Heads Up Notification When My android app is background.

When my app is open, Heads Up Notification appears but if the app is background or closed, it just showing on the normal status bar.

I tried on many other resources and read also in stack overflow similar questions.

But I didn't get a useful solution yet. Is it possible to show Heads Up Notification even when the app is background?


Solution

  • Firebase Cloud Messaging has two types of messages:

    • Notification messages, which are delivered to your application code if it is active, and are handled by the system when your app is not active.
    • Data messages, which are always delivered to your application code.

    From what you're describing it sounds like you're sending a notification message. If you always want your application code to handle the message, so that you control how it is displayed, you'll want to send a data message instead.

    For more on messages types, see: