admin管理员组

文章数量:1278853

Issue with Image/Icon Not Showing in Push Notification on iOS (Flutter & Laravel FCM)

I'm facing an issue where the image/icon in my push notifications is not showing when the app is terminated or running in the background on iOS. However, it works fine when the app is open.

I'm using Flutter for the frontend and Laravel for sending push notifications via Firebase Cloud Messaging (FCM). I'm not sure if the problem is in my payload structure or in Flutter’s handling of notifications.

Here is my Laravel payload:

$payload = [
    'message' => [
        'token' => $fcmToken,
        'apns' => [
            'headers' => [
                'apns-push-type' => 'alert',
                'apns-priority' => '10',
                'apns-topic' => 'com.test.testing',
            ],
            'payload' => [
                'aps' => [
                    'alert' => [
                        'title' => $title,
                        'body' => $body,
                    ],
                    'sound' => 'default',
                    'mutable-content' => 1,
                    'content-available' => 1,
                ],
            ],
        ],
        'data' => array_merge($formattedData, [
            'image' => $avatarUrl,
        ]),
        'android' => [
            'priority' => 'high'
        ],
    ],
];

I've set mutable-content to 1, but the image still doesn't appear in the notification when the app is terminated or in the background.

Has anyone encountered this issue before? Do I need to adjust my payload, or is there something I need to configure in Flutter?

Any help would be appreciated!

Issue with Image/Icon Not Showing in Push Notification on iOS (Flutter & Laravel FCM)

I'm facing an issue where the image/icon in my push notifications is not showing when the app is terminated or running in the background on iOS. However, it works fine when the app is open.

I'm using Flutter for the frontend and Laravel for sending push notifications via Firebase Cloud Messaging (FCM). I'm not sure if the problem is in my payload structure or in Flutter’s handling of notifications.

Here is my Laravel payload:

$payload = [
    'message' => [
        'token' => $fcmToken,
        'apns' => [
            'headers' => [
                'apns-push-type' => 'alert',
                'apns-priority' => '10',
                'apns-topic' => 'com.test.testing',
            ],
            'payload' => [
                'aps' => [
                    'alert' => [
                        'title' => $title,
                        'body' => $body,
                    ],
                    'sound' => 'default',
                    'mutable-content' => 1,
                    'content-available' => 1,
                ],
            ],
        ],
        'data' => array_merge($formattedData, [
            'image' => $avatarUrl,
        ]),
        'android' => [
            'priority' => 'high'
        ],
    ],
];

I've set mutable-content to 1, but the image still doesn't appear in the notification when the app is terminated or in the background.

Has anyone encountered this issue before? Do I need to adjust my payload, or is there something I need to configure in Flutter?

Any help would be appreciated!

Share Improve this question asked Feb 25 at 9:22 Chhean LymengChhean Lymeng 11 bronze badge 1
  • You need to add Notification Service Extension as well. – sonle Commented Feb 25 at 9:30
Add a comment  | 

1 Answer 1

Reset to default 0

There are some values that we need to update in your request. Check the example below for things that need updating.

message = {
  notification: {
      title: 'Sparky says hello!'
      },
  android: {
      notification: {
          imageUrl: 'https://foo.bar.pizza-monster.png'
          }
      },
  apns: {
    payload: {
      aps: {
        'mutable-content': 1
        }
      },
      fcm_options: {
         image: 'https://foo.bar.pizza-monster.png'
         }
      },
      webpush: {
         headers: {
         image: 'https://foo.bar.pizza-monster.png'
         }
      },
      topic: topicName,
 };

for more details please click here

本文标签: Issue with ImageIcon Not Showing in Push Notification on iOS (Flutter amp Laravel FCM)Stack Overflow