public void backGroundNotification() {
Intent intent = new Intent(this, MainActivity.class);
// Send data to NotificationView Class
intent.putExtra("title", title);
intent.putExtra("text", body);
intent.putExtra("imageUrl", imageUrl);
intent.putExtra("type", type);
intent.putExtra("id", id);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
pendingIntentPromo = PendingIntent.getActivity(this,0,intent, PendingIntent.FLAG_ONE_SHOT);
new LoadBitmap().execute("");
}
private class LoadBitmap extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... params) {
try {
bit = Glide.
with(MyFirebaseMessagingService.this).
load(imageUrl).
asBitmap().
into(100, 100). // Width and height
get();
} catch (Exception e) {
e.printStackTrace();
Log.e("noti exp", e + "");
}
return null;
}
@Override
protected void onPostExecute(String s1) {
if (bit != null) {
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(MyFirebaseMessagingService.this)
.setSmallIcon(R.drawable.app_icon)
.setContentTitle(title)
.setContentText(body)
.setAutoCancel(true)
.setTicker("DealDio")
.setSound(sound)
.setVibrate(vibration)
.setContentIntent(pendingIntentPromo)
.setStyle(new NotificationCompat.BigPictureStyle()
.bigPicture(bit)
.bigLargeIcon(null)
.setSummaryText(body));
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notificationBuilder.build());
}
}
}
I have search lot of things for it, but always found solution for get notification in background or data payload issue. According to me, bitmap not create in background.
I am already using data payload and got notification in background, and its shows in notification bar, but expandable image not show were as in foreground it works fine.