react-native - 世博会本地通知如何设置每天开始和重复的时间?
问题描述
我很难弄清楚最新版本的世博会如何在一天中的特定时间设置本地通知并使其每天重复。
- package.json 中的相关部分
"expo": "~40.0.0",
"expo-notifications": "~0.8.2",
- 我可以使用这个 sipets 创建通知
function startsTomorowButNotAbleToRepeateEvryDay() {
let tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
tomorrow.setHours(20);
tomorrow.setMinutes(0);
return {
content: {
title: "Time to study v2",
body: "Don't forget to study today!",
},
trigger: tomorrow,
};
}
function repeatsEvryDayButNotPossibleToSetTime() {
const seccondsInADay = 24 * 60 * 60;
return {
content: {
title: "Time to study v2",
body: "Don't forget to study today!",
},
trigger: {
seconds: seccondsInADay,
repeats: true,
},
};
}
- 这就是使用方式
Notifications.scheduleNotificationAsync(startsTomorowButNotAbleToRepeateEvryDay());
Notifications.scheduleNotificationAsync(repeatsEvryDayButNotPossibleToSetTime());
如何从明天的特定时间开始通知并每天重复?
解决方案
来自 Notifications.types.d.ts
export interface DailyTriggerInput {
channelId?: string;
hour: number;
minute: number;
repeats: true;
}
您可以使用:
trigger: {
hour: 19;
minute: 45;
repeats: true;
}
推荐阅读
- javascript - 是否可以更改“annotationStyleEditButton”和“annotationDeleteButton”的 webviewer 按钮图标
- typescript - 在我的 nativescritp 应用程序中为 backend.service.ts 导入 kinvey 时出错
- python - 为自定义损失函数创建形状与模型输出相同的 keras 张量
- amazon-iam - RDS 实例能否代入另一个账户的角色?
- python - Python 从 txt 文件中逐行加入
- python - 如何更改标签小部件中文本的位置?
- java - 如何从 Eclipse 中获取 .java 文件
- javascript - 如何使用 React Hooks 将状态值传递给回调函数
- c# - “Java.Lang.SecurityException:'我的位置需要权限 ACCESS_FINE_LOCATION 或 ACCESS_COARSE_LOCATION'”出现问题
- authorization - 如何使用速度检索 liferay authToken