2
    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.

AL.
  • 36,815
  • 10
  • 142
  • 281
Rahul Sharma
  • 121
  • 1
  • 8
  • I got this refrence, but its not working in for me on https://stackoverflow.com/questions/38504078/firebase-expandable-notification-show-image-when-app-is-in-background – Rahul Sharma May 10 '18 at 11:51
  • Did you solve this issue?? – SOBIR N Aug 25 '19 at 07:12
  • @RahulSharma can you share the response you are getting from the server? when you are receiving the payload with the notification? I mean the format, please. – A S M Sayem Oct 27 '19 at 19:29
  • https://stackoverflow.com/a/62451681/3037523, see this reason maybe occurring to you. – mhtamun Jun 18 '20 at 13:57

0 Answers0