HarmonyOS 查询不到用户在系统日历中添加的日程?

1、getEvents接口只能查询出通过接口addEvent添加的日程,用户自己在系统日历中添加的日程查询不到,是不支持查询吗?我们有需求去查询用户自己在系统日历里的日程。

2、先通过接口addEvent添加日程,设置了recurrenceRule重复规则,再去查询这个日程,recurrenceRule=undefined,系统日历中也只有一条日程,没有按重复规则添加的其他日程。手动在系统日历中把这条日程改成有重复规则的日程,再次通过接口getEvents查询,还是最开始的日程,还是没有recurrenceRule。

3、先通过接口addEvent添加日程,设置了identifier=util.generateRandomUUID(),再去查询这个日程,identifier= undefined。不管设置成什么,始终查询不到identifier

阅读 590
1 个回答

1 安全隐私问题,只能拿到本应用添加的日程,用户或其他应用的无法查询

2 recurrenceRule重复规则在beta2版本开始生效

3 使用calendar.getEvents需要指定 条件recurrenceRule,identifier才能查询到

const filter = calendarManager.EventFilter.filterByTitle('MyEvent1');
calendar.getEvents(filter, ['title', 'type', 'startTime', 'endTime','identifier','recurrenceRule'],).then((data: calendarManager.Event[]) => {
  console.info(`Succeeded to filter by title, data -> ${JSON.stringify(data)}`);
}).catch((err: BusinessError) => {
  console.error(`Failed to filter by title, err -> ${JSON.stringify(err)}`);
});
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进