react-native - 世博会每周通知在 Android 上
问题描述
我坚持尝试让我的世博会应用程序每周发送推送通知。在文档中,我读到我应该使用 WeeklyTriggerInput 接口作为我的触发器对象,但是当我尝试这样做时,我得到“无法安排通知。触发器类型:Android 不支持日历。” 错误。我也无法从 expo-notifications 导入 WeeklyTriggerInput 接口。这是我的代码:
const notificationParams: Notifications.NotificationRequestInput = {
content: {
title: 'Just title',
body: 'Lorem ipsum',
},
trigger: {
hour: 13,
minute: 10,
repeats: true,
weekday: 1,
},
};
try {
const notificationId = await Notifications.scheduleNotificationAsync(
notificationParams
);
} catch (err) {
console.log(err);
}
解决方案
通过遵循文档示例,这个片段对我有用:
const id = await Notifications.scheduleNotificationAsync({
content: {
title: "Dia de planejar sua alimentação! ",
body: 'Utilize uma de nossas receitas, crie suas próprias, experimente novas combinações ou veja a sugestão de um nutricionista.',
},
trigger: {
repeats: true,
weekday: 1, //Sunday
hour: 8,
minute: 0
},
});
推荐阅读
- java - Hibernate 延迟属性加载。使用@DynamicUpdate 进行误报字段检测
- java - 多态数组排序中的转换错误
- c# - 如何使用 Ajax 将数字列表从网页发送到服务器
- r - 在R中创建位置的窗口间隔
- docker - 更改根目录后,docker build 权限被拒绝
- linux - 使用 systemd 插入 USB 驱动器时如何触发脚本
- django - TypeError:字段“价格”需要一个数字,但得到了
- reactjs - 如何使用路由器和 Redux 渲染 react-testing-library?
- python - 如何在 Python 中多次调用函数?
- javascript - 使用 promise-pool 和 puppeteer 创建一个持续增加的列表