You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PlayFab CloudScript:如何在推送通知中设置大图片(横幅)

如何在PlayFab CloudScript推送通知中添加大图片横幅?

你可以通过PlayFab SendPushNotification API的CustomData字段,传递FCM所需的图片参数来实现大图片横幅效果,对应你在Firebase控制台中设置的“图片URL”功能。

修改后的完整代码

handlers.sendPushNotification = (args, context) => {
  try {
    const bigPictureUrl = "https://firebasestorage.googleapis.com/v0/b/project-id.appspot.com/o/FCMImages%2Fnotification-banner-7.png";
    server.SendPushNotification({
      Recipient: currentPlayerId,
      Package: {
        Title: "Test",
        Message: "This is a test",
        // 添加自定义FCM负载,设置大图片URL
        CustomData: {
          "notification": {
            "image": bigPictureUrl
          }
        }
      }
    });
    return {};
  } catch (err) {
    // 可选:添加错误日志便于排查
    server.WritePlayerEvent({
      EventName: "PushNotificationError",
      Body: { Error: err.message }
    });
    return { Error: err.message };
  }
};

关键说明

  • PlayFab的CustomData会直接作为FCM推送负载的一部分传递,这里的notification.image对应Firebase控制台中设置的图片URL,适用于系统自动展示的通知消息。
  • 如果你的客户端是自定义处理推送(数据消息模式),则需要改用data字段传递参数,示例如下:
    CustomData: {
      "data": {
        "big_picture": bigPictureUrl
      }
    }
    
    这种情况下,你需要在客户端代码中解析big_picture字段并手动展示图片。

内容的提问来源于stack exchange,提问作者Hasan Yousef

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.26 11:52:06