FCM notification not showing image on all devices

I have multiple devices (both Android and IOS) subscribed to same topic (e.g. “all”/”unregistered”)
I am sending FCM notification through postman,
I am able to successfully able to receive notification on all devices, but when I add image url to notification all devices receive notification but some devices are showing notification image.

This is my Json for sending notification from postman

{
  "to": "/topics/all",
  "notification": {
    "body": "Notification Body Content",
    "title": "Notification title content",
    "image": "https://images.pexels.com/photos/1108099/pexels-photo-1108099.jpeg",
    "sound": "default"
  },
  "apns": {
    "headers": {
      "apns-priority": "10"
    },
    "payload": {
      "aps": {
        "content-available": 1,
        "sound": "default",
        "alert": {
          "body": "Notification body",
          "title": "Notification title"
        }
      }
    }
  },
  "android": {
    "priority": "high",
    "notification": {
      "sound": "default"
    }
  },
  "data": {
    "goToScreen":"",
    "redirectionUrl":"",
    "redirection": "1",
    "redirectToExternalApp": "0",
    "redirectInsideApp": "1"
  }
}

below is the code that I used to handle notification

filename : notification_utils.dart

class FCMServices {
  static RemoteMessage? initialMessage;
  static String? messageId;
  static FirebaseMessaging messaging = FirebaseMessaging.instance;

  static Future<void> requestNotificationPermission() async {
    // Request notification permission on IOS
    if (GetPlatform.isIOS) {
      NotificationSettings settings = await messaging.requestPermission(
        alert: true,
        announcement: false,
        badge: true,
        carPlay: false,
        criticalAlert: false,
        provisional: false,
        sound: true,
      );

      if (settings.authorizationStatus == AuthorizationStatus.authorized) {
        // print('User granted permission');
      } else if (settings.authorizationStatus ==
          AuthorizationStatus.provisional) {
        // print('User granted provisional permission');
      } else {
        // print('User declined or has not accepted permission');
      }
      // print("### ${settings.authorizationStatus.toString()}");
    } else {
      // Request notification permission on Android
      PermissionStatus notificationStatus =
          await Permission.notification.request();
      if (notificationStatus.isDenied) {
        // Generating demo notification because to register notification channelID
        // to display notification as a heads up notificaiton
        LocalNotificationService.demoNotification();
      }
    }
  }

  static Future<void> getInitialMessage() async {
    initialMessage = await messaging.getInitialMessage();
  }

  static void setupAppOpenListener() {
    FirebaseMessaging.onMessageOpenedApp.listen(_handleMessage);
  }

  static void handleNotificationInForground() async {
    FirebaseMessaging.onMessage.listen((message) {
      if (message.notification != null) {
        requestNotificationPermission();
        LocalNotificationService.display(message);

      }
    });
  }


  static Future<void> setupInteractedMessage() async {
    // If the message also contains a data property with a "goToScreen"
    if (initialMessage != null) {
     
      if (initialMessage!.messageId != messageId) {
        messageId = initialMessage!.messageId;
      
        await _handleMessage(initialMessage!);
      }
      initialMessage = null;
    }

  
    FirebaseMessaging.onMessageOpenedApp.listen(_handleMessage);
  }

  static void handleBackgroundMessages() {
    FirebaseMessaging.onBackgroundMessage(_handleMessage);
  }

  // DESCRIPTION: Handeling remote message
  static Future<void> _handleMessage(RemoteMessage message) async {
        // This will handle rest of stuff
    }

 static void setupAppOpenListener() {
    FirebaseMessaging.onMessageOpenedApp.listen(_handleMessage);
  }

}

And here is the code I wrote in main.dart file

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  
  await FCMServices.getInitialMessage();
  FCMServices.setupAppOpenListener();

  //this is to setup device orientation of the app
  await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);

  runApp(const Root());
}

this is code from backend

public function sendNotificationToAllUsers($notificationData){

                    $title = $notificationData['title'];
                    $message = $notificationData['message'];
                    $type = $notificationData['type'];
                    $process_type = $notificationData['process_type'];
                    $process_date = $notificationData['process_date'];
                    $process_time = $notificationData['process_time'];
                    $user_id = $notificationData['user_id'];
                    $product_id = $notificationData['product_id'];
                    $images = $notificationData['images'];

                    $notification = ['body' => $message, 'title' => $title, 'image' => $images, 'sound' => 'default'];
                    $notification1 = ['body' => $message, 'title' => $title, 'image' => $images];
                    $data = ['screen' => 2, 'product_id' => $product_id];

                    $apns = [
                        'headers' => ['apns-priority' => '10'],
                        'payload' => [
                            'aps' => [
                                'content-available' => 1,
                                'sound' => 'default',
                                'alert' => $notification1
                            ]
                        ]
                    ];

                    $android = ['priority' => 'high', 'notification' => ['sound' => 'default']];
                     $fcmNotification = [
                                     'to' => '/topics/all',
                                     'notification' => $notification,
                                     'apns'=>$apns,
                                     'android'=>$android,
                                     'data'=>$data
                            ]; 
                    $ch = curl_init();
                    curl_setopt($ch, CURLOPT_URL, $this->fcmUrl);
                    curl_setopt($ch, CURLOPT_POST, true);
                    curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
                    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fcmNotification));
                    $result = curl_exec($ch);


            }

I am using

  1. flutter version 3.13.0

  2. dart version 3.1.0

  3. firebase_messaging: ^14.7.10

  4. firebase_core: ^2.24.2

  5. Followed official firebase documentation

NOTE : I have code that subscribes to topic called “all” in my code which is not provided here, also I have all the required permissions to display notification on both android and IOS device

New contributor

what Now is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật