Javed Ali
Javed Ali

Reputation: 1

How to Get both Notification and data when app is background in android

How to Get both Notification and data when app is background in android.

When app is foreground than get both Notification and data.

But when app in background than get only data.

I want Get both Notification and data when app is background.

Upvotes: 0

Views: 58

Answers (1)

Reza Abedi
Reza Abedi

Reputation: 448

As i searched it's not possible. you can pass Notification parameters to data and get them in

@Override
public void onMessageReceived(RemoteMessage remoteMessage){
 createNotification(remoteMessage.getData());
}
private void createNotification(Map<String, String> data) {
....
 NotificationCompat.Builder mNotificationBuilder = new NotificationCompat.Builder(this, channelId)
            .setSmallIcon(R.mipmap.ic_icon)
            .setContentTitle(data.get("title"))
            .setContentText(data.get("body"))
}

Upvotes: 1

Related Questions