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.koksalb– koksalb2018-09-06 11:49:19 +00:00Commented Sep 6, 2018 at 11:49
-
Custom UI of notification does not show when app is in background.Muhammad Zahab– Muhammad Zahab2018-09-06 11:52:05 +00:00Commented Sep 6, 2018 at 11:52
Add a comment
|
2 Answers
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 :)
3 Comments
LearnFromYou
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.
Muhammad Zahab
Notifications are showing but there UI creating issue when app is in background
Javad Shakouri
The problem was solved ? I have problems in such cases
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);
}
}