1

I have implemented push notifications for my app with customized layout.When app is in foreground and notification came everything works fine and layout of Notification is showing as i created. But when application is in background then Custom UI of the notification does not show up but it shows some default UI of notification.

2
  • can you be more clear about what "not showing" means? do you mean the notification functionality does not work, or that you receive the notification but the UI of the notification does not show. In case you receive nothing, it is pretty normal unless you write an android service that runs in the background (like sticky service) that listens your notifications. Commented Sep 6, 2018 at 11:49
  • Custom UI of notification does not show when app is in background. Commented Sep 6, 2018 at 11:52

2 Answers 2

1

It is a bit hard, to figure out your problem without code samples, but did you use RemoteViews?

When I tried what you are stating in your question I experienced a simular problem, because I didnt use Remote Views in a proper way.

I hope I could help you out :)

Sign up to request clarification or add additional context in comments.

3 Comments

Do you have a Click-Action -> "click_action" : ".MainActivity" in your Notification sceleton and an Intent-Filter in your Manifest.xml where your activity is declared? They are both necessary to show custom notifications when App is background.
Notifications are showing but there UI creating issue when app is in background
The problem was solved ? I have problems in such cases
1

override handleIntent in your FirebaseMessagingService and add the following code. this will help to show your custom layout when app is in background or killed

@Override
public void handleIntent(Intent intent) {
    try {
        if (intent.getExtras() != null) {
            RemoteMessage.Builder builder = new RemoteMessage.Builder("MyFirebaseMessagingService");
            for (String key : intent.getExtras().keySet()) {
                builder.addData(key, intent.getExtras().get(key).toString());
            }
            onMessageReceived(builder.build());
        } else {
            super.handleIntent(intent);
        }
    } catch (Exception e) {
        super.handleIntent(intent);
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.