世博会“ scheduleLocalNotificationAsync”图标未更改

时间:2020-09-13 16:06:47

标签: react-native notifications expo

您好,我正在尝试为本地通知设置图标(scheduleLocalNotificationAsync(localNotification, schedulingOptions)),该图标将在一段时间后显示。但是,无论何时设置图标并触发通知。默认的Expo图标将始终显示在通知中,而不是我设置的图标。 enter image description here

以下是安排通知的代码:

const localNotification = {
      title: item.name,
      body: 'Your ' + item.name + ' Tree is Ready',
      icon: "../../assets/img_acorn_tree.png",
      ios: {
        sound: true
      },
      android:
      {
        sound: true,
        priority:'high',
        icon: "../../assets/img_acorn_tree.png",
        sticky: false,
        vibrate: true
      }
    };

    let t = new Date();
    t.setSeconds(t.getSeconds() + 10);
    const schedulingOptions = {
      time: t,
    };

    const id = Notifications.scheduleLocalNotificationAsync(localNotification, schedulingOptions)

如您所见,创建通知时我尝试分配图标。

我还试图更改app.json文件中的图标

  "expo": {
    ...
    ],
    "notification": {
      "icon":"./assets/img_acorn_tree.png"
    },
    ...
}

还有办法将通知的主标题从“ Expo”更改为其他内容吗?

任何反馈都将受到高度赞赏。

谢谢

0 个答案:

没有答案