更新记录

1.2.0(2022-08-10)

本次主要更新: 1.修复查询事件,只能查询2021年的bug

1.1.0(2022-02-24)

本次主要更新: 1.添加提醒事项,title没有设置成功

1.0.0(2021-06-01)

首次更新

查看更多

平台兼容性

Android iOS
× 适用版本区间:9 - 16

原生插件通用使用流程:

  1. 购买插件,选择该插件绑定的项目。
  2. 在HBuilderX里找到项目,在manifest的app原生插件配置中勾选模块,如需要填写参数则参考插件作者的文档添加。
  3. 根据插件作者的提供的文档开发代码,在代码中引用插件,调用插件功能。
  4. 打包自定义基座,选择插件,得到自定义基座,然后运行时选择自定义基座,进行log输出测试。
  5. 开发完毕后正式云打包

付费原生插件目前不支持离线打包。
Android 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/android
iOS 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/ios

注意事项:使用HBuilderX2.7.14以下版本,如果同一插件且同一appid下购买并绑定了多个包名,提交云打包界面提示包名绑定不一致时,需要在HBuilderX项目中manifest.json->“App原生插件配置”->”云端插件“列表中删除该插件重新选择


KJ-AddCalendarEvent

日历、提醒事项 添加日程和提醒(ios)

引入插件

const KJAddCalendarEventModule = uni.requireNativePlugin('KJ-AddCalendarEventModule');

相关代码

<template>
    <view>
        <button type="primary" @click="requestAccess">请求使用用户的日历数据库</button>

        <button type="primary" @click="saveEvent">保存事件(日程)</button>
        <button type="primary" @click="inquireEvent">查询事件(日程)</button>
        <button type="primary" @click="removeEvent">删除事件(日程)</button>

        <button type="primary" @click="saveReminder">保存提醒事项</button>
        <button type="primary" @click="inquireReminder">查询提醒事项</button>
        <button type="primary" @click="removeReminder">删除提醒事项</button>

        <button type="primary" @click="commit">提交</button>

        <button type="primary" @click="showEventEditVC_add">显示系统(添加)事件界面</button>
        <button type="primary" @click="showEventEditVC_edit">显示系统(编辑)事件界面</button>
    </view>
</template>

<script>
    const KJAddCalendarEventModule = uni.requireNativePlugin('KJ-AddCalendarEventModule');

    export default {
        onLoad() {

        },
        methods: {
            requestAccess() {
                KJAddCalendarEventModule.requestAccess({
                    "entityType": "Event" //Event-事件(日程),Reminder-提醒事项
                }, (res) => {
                    console.log(JSON.stringify(res))
                    if (res.granted) {
                        console.log("可以使用")
                    }else {
                        console.log("不可以使用,原因:"+res.error);
                    }
                });
            },
            saveEvent() {
                //请求使用用户的日历数据库
                KJAddCalendarEventModule.requestAccess({
                    "entityType": "Event" //Event-事件(日程),Reminder-提醒事项
                }, (res) => {
                    console.log(JSON.stringify(res))
                    if (res.granted) {
                        KJAddCalendarEventModule.saveEvent({
                            "eventIdentifier": null, //事件唯一ID,如果不为null,则是编辑当前,为null,则新增
                            "title": "标题",
                            "location": "位置信息",
                            "notes": "备注",
                            "startDateStr": "2021-5-1 01:00:00", //开始时间,日期格式yyyy-MM-dd HH:mm:ss
                            "endDateStr": "2021-12-31 01:00:00", //结束时间,日期格式yyyy-MM-dd HH:mm:ss
                            "allDay": false, //是否全天
                            "URLStr": "",
                            "alarms": [{ //提醒
                                "dateStr": "2021-5-26 17:00:00"//提醒时间,日期格式yyyy-MM-dd HH:mm:ss
                            }],
                            "recurrenceRules": [{ //重复
                                "frequency": "Daily", //重复的类型 Daily->按天; Weekly->按周; Monthly->按月; Yearly->按年
                                "interval": 1, //间隔
                                "daysOfTheWeeks": [{//数组。适用于除每日以外的所有重复类型。否则忽略。
                                    "dayOfWeek": 5,//星期几 1->星期天;2->星期一;3->星期二;4->星期三;5->星期四;6->星期五;7->星期六;
                                    "weekNumber": 1//周数
                                }],
                                "daysOfTheMonths": [],//数组([+/-] 1 到 31)。负数推断从月底开始计数。例如,-1 表示该月的最后一天。仅对每月重复有效。否则忽略。
                                "monthsOfTheYears": [],//数组(1到12)。仅对年度重复有效。否则忽略
                                "weeksOfTheYears": [],//数组([+/1] 1 到 53)。负数推断从年底开始计数。例如,-1 表示一年中的最后一周。仅对年度重复有效。否则忽略。
                                "daysOfTheYears": [],//数组([+/1] 1 到 366)。负数推断从年底开始计数。例如,-1 表示一年的最后一天。仅对年度重复有效。否则忽略。
                                "setPositions": [],//数组([+/1] 1 到 366)。在循环计算结束时用于过滤列表 到指定的位置。负数表示从末尾开始,即 -1 表示取集合的最后结果
                                "endDateStr": "",//循环结束时间
                            }],
                            "structuredLocation": { //位置
                                "title": "", //标题
                                "latitude": 0, //纬度
                                "longitude": 0, //经度
                                "radius": 0 //半径
                            },
                            "span": "ThisEvent", //ThisEvent->仅影响当前事件  FutureEvents->影响这个事件及其后的一切
                            "commit": true //false 暂存当前事件 但不提交到系统日历   true 立即提交存入系统日历
                        }, (res) => {
                            console.log(JSON.stringify(res))
                        })
                    }
                });
            },
            inquireEvent() {
                KJAddCalendarEventModule.requestAccess({
                    "entityType": "Event" //Event-事件(日程),Reminder-提醒事项
                }, (res) => {
                    console.log(JSON.stringify(res))
                    if (res.granted) {
                        KJAddCalendarEventModule.inquireEvent({
                            "startDateStr": "2021-1-1 0:0:0", //开始时间,日期格式yyyy-MM-dd HH:mm:ss
                            "endDateStr": "2021-12-31 0:0:0", //结束时间,日期格式yyyy-MM-dd HH:mm:ss
                            "isFilterSameEventIdentifier": false //是否过滤相同的eventIdentifier
                        }, (res) => {
                            console.log(JSON.stringify(res))
                        })
                    }
                });
            },
            removeEvent() {
                KJAddCalendarEventModule.requestAccess({
                    "entityType": "Event" //Event-事件(日程),Reminder-提醒事项
                }, (res) => {
                    console.log(JSON.stringify(res))
                    if (res.granted) {
                        KJAddCalendarEventModule.inquireEvent({
                            "startDateStr": "2021-1-1 0:0:0", //开始时间,日期格式yyyy-MM-dd HH:mm:ss
                            "endDateStr": "2021-12-31 0:0:0", //结束时间,日期格式yyyy-MM-dd HH:mm:ss
                            "isFilterSameEventIdentifier": false //是否过滤相同的eventIdentifier
                        }, (res) => {
                            console.log(JSON.stringify(res))
                            var arr = res.result;
                            var dic = arr[0];
                            KJAddCalendarEventModule.removeEvent({
                                "eventIdentifier": dic.eventIdentifier,
                                "span": "ThisEvent", //ThisEvent->仅影响当前事件  FutureEvents->影响这个事件及其后的一切
                                "commit": true //false 暂存当前事件 但不提交到系统日历   true 立即提交存入系统日历
                            }, (res) => {
                                console.log(JSON.stringify(res))
                            })
                        })
                    }
                });
            },
            saveReminder() {
                KJAddCalendarEventModule.requestAccess({
                    "entityType": "Reminder" //Event-事件(日程),Reminder-提醒事项
                }, (res) => {
                    console.log(JSON.stringify(res))
                    if (res.granted) {
                        KJAddCalendarEventModule.saveReminder({
                            "title": "标题",
                            "startDateComponentsStr": "2021-5-1 01:00:00", //开始提醒的日期,日期格式yyyy-MM-dd HH:mm:ss
                            "dueDateComponentsStr": "2021-12-31 01:00:00", //预期完成提醒的日期,日期格式yyyy-MM-dd HH:mm:ss
                            "completed": false, //设置true将把实际完成的日期设置为当前日期。
                            "completionDateStr": "", //实际完成提醒的日期,日期格式yyyy-MM-dd HH:mm:ss
                            "priority": 0, //优先级1-4被认为是“高”,优先级5被认为是“中”,而优先级6-9被认为是“低”。
                            "alarms": [{ //提醒
                                "dateStr": "2021-5-26 17:00:00"//提醒时间,日期格式yyyy-MM-dd HH:mm:ss
                            }], 
                            "recurrenceRules": [{ //重复
                                "frequency": "Daily", //重复的类型 Daily->按天; Weekly->按周; Monthly->按月; Yearly->按年
                                "interval": 1, //间隔
                                "daysOfTheWeeks": [{//数组。适用于除每日以外的所有重复类型。否则忽略。
                                    "dayOfWeek": 5,//星期几 1->星期天;2->星期一;3->星期二;4->星期三;5->星期四;6->星期五;7->星期六;
                                    "weekNumber": 1//周数
                                }],
                                "daysOfTheMonths": [],//数组([+/-] 1 到 31)。负数推断从月底开始计数。例如,-1 表示该月的最后一天。仅对每月重复有效。否则忽略。
                                "monthsOfTheYears": [],//数组(1到12)。仅对年度重复有效。否则忽略
                                "weeksOfTheYears": [],//数组([+/1] 1 到 53)。负数推断从年底开始计数。例如,-1 表示一年中的最后一周。仅对年度重复有效。否则忽略。
                                "daysOfTheYears": [],//数组([+/1] 1 到 366)。负数推断从年底开始计数。例如,-1 表示一年的最后一天。仅对年度重复有效。否则忽略。
                                "setPositions": [],//数组([+/1] 1 到 366)。在循环计算结束时用于过滤列表 到指定的位置。负数表示从末尾开始,即 -1 表示取集合的最后结果
                                "endDateStr": "",//循环结束时间
                            }],
                            "commit": true //false 暂存当前事件 但不提交到系统日历   true 立即提交存入系统日历
                        }, (res) => {
                            console.log(JSON.stringify(res))
                        })
                    }
                });
            },
            inquireReminder() {
                KJAddCalendarEventModule.requestAccess({
                    "entityType": "Reminder" //Event-事件(日程),Reminder-提醒事项
                }, (res) => {
                    console.log(JSON.stringify(res))
                    if (res.granted) {
                        KJAddCalendarEventModule.inquireReminder((res) => {
                            console.log(JSON.stringify(res))
                        })
                    }
                });
            },
            removeReminder() {
                KJAddCalendarEventModule.requestAccess({
                    "entityType": "Reminder" //Event-事件(日程),Reminder-提醒事项
                }, (res) => {
                    console.log(JSON.stringify(res))
                    if (res.granted) {
                        KJAddCalendarEventModule.removeReminder({
                            "index": 0, //inquireReminder 查询到的index
                            "commit": true //false 暂存当前事件 但不提交到系统日历   true 立即提交存入系统日历
                        }, (res) => {
                            console.log(JSON.stringify(res))
                        })
                    }
                });
            },
            commit() {
                KJAddCalendarEventModule.requestAccess({
                    "entityType": "Event" //Event-事件(日程),Reminder-提醒事项
                }, (res) => {
                    console.log(JSON.stringify(res))
                    if (res.granted) {
                        KJAddCalendarEventModule.commit((res) => {
                            console.log(JSON.stringify(res))
                        })
                    }
                });
            },
            showEventEditVC_add() {
                KJAddCalendarEventModule.requestAccess({
                    "entityType": "Event" //Event-事件(日程),Reminder-提醒事项
                }, (res) => {
                    console.log(JSON.stringify(res))
                    if (res.granted) {
                        KJAddCalendarEventModule.showEventEditVC({
                            "eventIdentifier": null, //事件唯一ID,如果不为null,则是编辑当前,为null,则新增
                        }, (res) => {
                            console.log(JSON.stringify(res))
                            var action = res.action;
                            if(action == "Canceled") {
                                console.log("取消")
                            }else if(action == "Saved") {
                                console.log("保存")
                            }else if(action == "Deleted") {
                                console.log("删除")
                            }
                        })
                    }
                });
            },
            showEventEditVC_edit() {
                KJAddCalendarEventModule.requestAccess({
                    "entityType": "Event" //Event-事件(日程),Reminder-提醒事项
                }, (res) => {
                    console.log(JSON.stringify(res))
                    if (res.granted) {
                        KJAddCalendarEventModule.inquireEvent({
                            "startDateStr": "2021-1-1 0:0:0", //开始时间,日期格式yyyy-MM-dd HH:mm:ss
                            "endDateStr": "2021-12-31 0:0:0", //时间,日期格式yyyy-MM-dd HH:mm:ss
                            "isFilterSameEventIdentifier": true //是否过滤相同的eventIdentifier
                        }, (res) => {
                            console.log(JSON.stringify(res))
                            var arr = res.result;
                            var dic = arr[0];
                            KJAddCalendarEventModule.showEventEditVC({
                                "eventIdentifier": dic
                                .eventIdentifier, //事件唯一ID,如果不为null,则是编辑当前,为null,则新增
                            }, (res) => {
                                console.log(JSON.stringify(res));
                                var action = res.action;
                                if(action == "Canceled") {
                                    console.log("取消")
                                }else if(action == "Saved") {
                                    console.log("保存")
                                }else if(action == "Deleted") {
                                    console.log("删除")
                                }
                            })
                        })
                    }
                });
            }
        },

    }
</script>

隐私、权限声明

1. 本插件需要申请的系统权限列表:

日历(NSCalendersUsageDescription)、提醒事项(NSRemindersUsageDescription)

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问