每3天无法安排展览通知

时间:2020-11-03 19:49:03

标签: reactjs notifications expo native schedule

我正在一个项目中,我希望每X天安排一次通知。 这是我安排通知的部分:

let notificationId = await Notifications.scheduleNotificationAsync({
        content: {
            title: title,
            body: body,
            data: null,
        },
        trigger: { day: freq, repeats: true },   
    }); 

我尝试过

        trigger: { hour: freq * 24, repeats: true },   

但是每次我收到此错误时: [未处理的承诺被拒绝:错误:无法安排通知。类型的触发器:Android不支持日历。]

我知道有些人可能会说这是因为我在模拟器上尝试过,但是它仍然可以正常工作,并确保我也可以在手机上尝试并且仍然无法正常工作。

1 个答案:

答案 0 :(得分:0)

试试这个

const trigger = await Notifications.getNextTriggerDateAsync({
                channelId: DECKS_NOTIFICATION_CHANNEL_ID, 
                hour: 20,
                minute: 0,
                repeats: true,
                //seconds: 2,
            })

然后

let notificationId = await Notifications.scheduleNotificationAsync({
    content: {
        title: title,
        body: body,
        data: null,
    },
    trigger   
}); 

SchedulabeNotificationTriggers 有很多种类型。我给你看的那个是每天用的。您可以在此链接中查看更多信息 Expo Notifications

相关问题