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

Expo自定义推送通知图标在Android设备无法显示的问题

推送通知图标无法替换Expo默认图标问题

我已经成功为Expo应用配置推送通知(标题和消息可正常显示),但始终无法替换默认的Expo倒V形图标,在Redmi Note 5和Samsung Galaxy S5两款设备上测试,推送通知图标均未遵循我根据官方文档设置的配置。

通知通过Python的exponent_server_sdk库发送,开发时通过命令行执行expo start启动应用,设备通过Expo App扫描二维码连接。

已尝试的操作

  • 按照官方文档在app.json中配置推送通知图标,配置内容如下:
{
  "expo": {
    "name": "BaseApp",
    "slug": "BaseApp",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./Image/icon.png",
    "userInterfaceStyle": "light",
    "splash": {
      "image": "./Image/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./Image/adaptive-icon.png",
        "backgroundColor": "#FFFFFF"
      },
      "permissions": [
        "CAMERA",
        "READ_INTERNAL_STORAGE",
        "WRITE_INTERNAL_STORAGE",
        "READ_EXTERNAL_STORAGE",
        "WRITE_EXTERNAL_STORAGE",
        "ACCESS_BACKGROUND_LOCATION"
      ]
    },
    "plugins": [
      [
        "expo-notifications",
        {
          "icon": "./Image/pleasework.png",
          "color": "#ffffff"
        }
      ]
    ],
    "notification": {
      "icon": "./Image/pleasework.png",
      "color": "#7f2ee1",
      "androidMode": "default",
      "androidCollapsedTitle": "Updates from Colab.notes",
      "iosDisplayInForeground": true
    },
    "web": {
      "favicon": "./Image/pleasework.png"
    }
  }
}
  • 将通知图标调整为96x96像素、透明白底的格式
  • 清除两台设备上Expo App的缓存,无效果
  • 尝试从服务器发送图片本地路径,代码如下:
from exponent_server_sdk import (
    DeviceNotRegisteredError,
    PushClient,
    PushMessage,
    PushServerError,
    PushTicketError
)

@staticmethod
def send_push_message(token, message):
    """
    Summary:
        Send a push notification to the target device.

    Args:
        token (str): Unique identifier of the phone device.
        message (str): Text to send to the target phone device.
    """
    data = {'icon': PATH_TO_APP_ICON} #Evaluates to ./Image/pleasework.png
    try:
        response = PushClient().publish(
            PushMessage(to=token,
                        title=PushNotification.TITLE,
                        body=message,
                        data=data))
  • 尝试将图标尺寸调整为72x72到200x200之间的多个规格,均无效果
  • 确认./Image/pleasework.png是相对于项目根目录的有效路径
  • 尝试将图标转换为Base64编码后通过推送通知发送,未生效

我目前没有苹果设备无法测试iOS端,请问还有什么方法可以尝试解决这个问题?

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.26 20:38:11