日程添加失败的回调函数 {"errMsg": "addPhoneRepeatCalendar:fail can only be invoked by user TAP gesture."}
addPhoneRepeatCalendar () {
const that = this
wx.getSetting({
success(res) {
if (!res.authSetting['scope.addPhoneCalendar']) {
wx.authorize({
scope: 'scope.addPhoneCalendar',
success() {
that.wxAddPhoneRepeatCalenda()
},
fail() {
wx.showToast({
title: '请先授权日历',
icon: 'none',
duration: 2000
})
that.setData({
canIUse: false
})
}
})
} else {
that.wxAddPhoneRepeatCalenda()
}
}
})
},
wxAddPhoneRepeatCalenda () {
let currentDate = new Date();
currentDate.setMonth(currentDate.getMonth() + 1);
let nextMonthTimestamp = currentDate.getTime();
wx.addPhoneRepeatCalendar({
title: `「小日常桑」别忘了打卡喔~`,
startTime: new Date().getTime()/1000,
endTime: nextMonthTimestamp/1000,
description: '「小日常桑」提醒您打卡时间到啦~',
alarm: true,
alarmOffset: '0',
repeatInterval: 'day',
success(res) {
console.log('日程添加成功的回调函数',res)
},
fail(res) {
console.log('日程添加失败的回调函数',res)
}
})
},
请问解决了吗 同问
需要用户点击,产生tap事件才能调用这个API。
错误信息中指出了 "addPhoneRepeatCalendar:fail can only be invoked by user TAP gesture.",这意味着
wx.addPhoneRepeatCalendar
只能在用户的触摸操作下才能被调用。请确保在调用wx.addPhoneRepeatCalendar
前,用户已经通过触摸操作触发了相关的事件。