Android Firebase推送通知,来自服务器的图像(php)在通知中不显示图像,而应用程序在后台

Android Firebase推送通知,来自服务器的图像(php)在通知中不显示图像,而应用程序在后台,php,android,firebase,firebase-cloud-messaging,Php,Android,Firebase,Firebase Cloud Messaging,我使用php(服务器)实现了带有图像的android firebase推送通知。当应用程序处于前台时,图像通知可以正常工作。但当应用程序处于后台时,只接收到带有标题和消息的通知,而不显示图像。我发送的一切都只是数据。请帮我解决这个问题 ` **PHP CODE** <?php define( 'API_ACCESS_KEY', 'xxxxxxxx' ); $message = array ( 'message' => "$body",

我使用php(服务器)实现了带有图像的android firebase推送通知。当应用程序处于前台时,图像通知可以正常工作。但当应用程序处于后台时,只接收到带有标题和消息的通知,而不显示图像。我发送的一切都只是数据。请帮我解决这个问题

`     
**PHP CODE**
<?php

define( 'API_ACCESS_KEY', 'xxxxxxxx' );


 $message = array
      (
    'message'   => "$body",
    'title' => "notification",
    'image'=> $image_url,
    'vibrate'=>1,




      );
$fields = array
        (
            'registration_ids'      => $regid,
            'data'  => $message,


        );


$headers = array
        (
            'Authorization: key=' . API_ACCESS_KEY,
            'Content-Type: application/json'
        );

    $ch = curl_init();
    curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );
    curl_setopt( $ch,CURLOPT_POST, true );
    curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
    curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
    curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
    curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
    $result = curl_exec($ch );
    curl_close( $ch );

echo $result;

}

`

您可以使用带有以下代码的自定义视图来加载图像

NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            Notification notification = notificationBuilder.build();
            notificationManager.notify(0, notification);
            if (remoteMessage.getData().get(IMAGE_URL) != null) {
                final NotificationTarget notificationTarget = new NotificationTarget(getApplicationContext(), largeRemoteViews, R.id.notification_image, notification, 0);
                new Handler(Looper.getMainLooper()).post(new Runnable() {
                    @Override public void run() {
                        Glide.with(getApplicationContext()).load(remoteMessage.getData().get(IMAGE_URL)).asBitmap().into(notificationTarget);
                    }
                });
            }

如果收到通知,请发布您的代码。@VadimEksler我发布了我的代码。我的问题是我在前台收到图像通知。。但在后台,只显示标题和消息作为通知,而不显示图像。感谢您在您的设备上启用节电模式?我以前遇到过这样的情况,这是问题的原因。@在我的状态中,没有人已禁用节能模式device@sundar你找到问题的解决办法了吗??
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            Notification notification = notificationBuilder.build();
            notificationManager.notify(0, notification);
            if (remoteMessage.getData().get(IMAGE_URL) != null) {
                final NotificationTarget notificationTarget = new NotificationTarget(getApplicationContext(), largeRemoteViews, R.id.notification_image, notification, 0);
                new Handler(Looper.getMainLooper()).post(new Runnable() {
                    @Override public void run() {
                        Glide.with(getApplicationContext()).load(remoteMessage.getData().get(IMAGE_URL)).asBitmap().into(notificationTarget);
                    }
                });
            }