If your users are receiving empty or blank push notifications on Android, especially after receiving several notifications in a row, the issue is likely related to how Android groups notifications.
This can happen if you are using a custom PushwooshNotificationFactory and have not correctly set a group ID for your notifications. When the group ID is missing or null, Android's attempt to create a summary notification for the group can result in an empty notification being displayed.
How to Fix It
To resolve this, you need to ensure a group ID is always set in your custom notification factory.
- Open the Java/Kotlin class in your project that extends
PushwooshNotificationFactory. - Locate the
NotificationCompat.Builderinstance within your code. - Make sure the
.setGroup()method is called on the builder. The recommended approach is to use the group ID provided in the push payload.
Here is an example of how to correctly set the group ID:
// Inside your custom PushwooshNotificationFactory
@Override
public NotificationCompat.Builder onGenerateNotification(PushMessage pushMessage) {
// ... your other builder configurations
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channel.getId())
// ... other settings like .setContentTitle(), .setContentText(), etc.
// Ensure the group is set.
// The best practice is to get it from the push data.
.setGroup(pushMessage.getGroupId());
return builder;
}
By setting a valid group ID, you ensure that Android can correctly group your notifications without displaying an empty summary.
Testing the Fix
To verify the fix, send three or more push notifications to a test device. If the empty summary notification no longer appears, the issue is resolved.
Comments
0 comments
Please sign in to leave a comment.