廣告

iPhone行事歷如何同步提醒事項(xiàng)?用自動(dòng)化腳本輕松實(shí)現(xiàn)

機(jī)智社區(qū) 2023-03-21 04:42

相信有不少人都會(huì)將臨時(shí)代辦事項(xiàng)記錄在iPhone“提醒事項(xiàng)”App內(nèi),如果想要將iOS“提醒事項(xiàng)”自動(dòng)同步到“行事歷”內(nèi)要怎么做?同步功能似乎需要依賴(lài)第三方App才能達(dá)成,那有沒(méi)有免費(fèi)又能快速解決的方案?

其實(shí)要讓iOS提醒事項(xiàng)與行事歷同步透過(guò)捷徑自動(dòng)化就能輕松實(shí)現(xiàn),這篇就來(lái)分享搭配自動(dòng)化Scripts腳本,實(shí)現(xiàn)每次透過(guò)iPhone提醒事項(xiàng)紀(jì)錄生活瑣碎的事情,都能自動(dòng)同步到行事歷內(nèi)。

通常iOS內(nèi)建“提醒事項(xiàng)”App,如果要將代辦事項(xiàng)同步到行事歷內(nèi),都要手動(dòng)點(diǎn)選才能搬移加入,這種做法非常不人性化,反而比較推薦讓行事歷與提醒事項(xiàng)同步會(huì)更智能又省時(shí),實(shí)現(xiàn)效果如下畫(huà)面,當(dāng)iPhone在提醒事項(xiàng)內(nèi)增加后,就會(huì)立即同步到行事歷內(nèi),省去要手動(dòng)搬移的步驟,實(shí)現(xiàn)步驟可參考底下iPhone行事歷如何同步提醒事項(xiàng)教學(xué):

如何將iPhone行事歷同步提醒事項(xiàng)教學(xué)

本篇教學(xué)不管是iPhone或iPad設(shè)備都能使用,系統(tǒng)需iOS14或iPadOS14或以上。

1.替iOS行事歷與提醒事項(xiàng)建立相同列表

要實(shí)現(xiàn)iPhone行事歷與提醒事項(xiàng)同步功能,要在兩款A(yù)pp內(nèi)都建立相同的列表名稱(chēng),后續(xù)才能同步。

先打開(kāi)“提醒事項(xiàng)”App,點(diǎn)選右下角“新增列表”,自訂想同步的列表名。

接下來(lái)開(kāi)啟iOS內(nèi)建“行事歷”App,點(diǎn)選底下“行事歷”會(huì)進(jìn)入行事歷列表清單,點(diǎn)選左下角“加入行事歷”。

輸入與“提醒事項(xiàng)”App相同的列表名稱(chēng),按下右上角“完成”,后續(xù)想將重要事情紀(jì)錄在同步的列表內(nèi)即可。

2.建立Scripts同步腳本

為了能夠?qū)崿F(xiàn)iPhone內(nèi)建行事歷與提醒事項(xiàng)同步,我們需要利用“ScriptsApp”來(lái)運(yùn)行自動(dòng)化JavaScript腳本。

  • ScriptableAppStore下載位置

下載并且打開(kāi)“Scripts”App,點(diǎn)選右上角“+”新增按鈕,會(huì)出現(xiàn)新的腳本頁(yè)面,點(diǎn)擊上方“UntitledScript”文字后,將名稱(chēng)改為“提醒事項(xiàng)同步行事歷”。

并且將后面的iOS提醒事項(xiàng)同步行事歷代碼直接復(fù)制貼上,按下“Done”關(guān)閉。

iOS提醒事項(xiàng)同步行事歷代碼

腳本原作者:汀力

vardur_month=1conststartDate=newDate()startDate.setMonth(startDate.getMonth()-dur_month)console.log(`日歷的開(kāi)始時(shí)間${startDate.toLocaleDateString()}`)constendDate=newDate()endDate.setMonth(endDate.getMonth()+dur_month)console.log(`日歷的結(jié)束時(shí)間${endDate.toLocaleDateString()}`)constreminders=awaitReminder.allDueBetween(startDate,endDate)console.log(`獲取${reminders.length}條提醒事項(xiàng)`)varcalendar=awaitCalendar.forEvents()//獲取日歷名和對(duì)應(yīng)的日歷varm_dict={}for(calofcalendar){m_dict[cal.title]=cal//console.log(`日歷:${cal.title}`)}constevents=awaitCalendarEvent.between(startDate,endDate,calendar)console.log(`獲取${events.length}條日歷`)varreminders_id_set=newSet(reminders.map(e=>e.identifier))//刪除日歷里提醒事項(xiàng)刪除的事項(xiàng)events_created=events.filter(e=>e.notes!=null&&e.notes.includes("[Reminder]"))for(leteventofevents_created){//console.warn(event.notes)letreg=/(\[Reminder\])\s([A-Z0-9\-]*)/letr=event.notes.match(reg)//if(r)console.log(r[2])if(!reminders_id_set.has(r[2])){event.remove()}}for(constreminderofreminders){//reminder的標(biāo)識(shí)符consttargetNote=`[Reminder]${reminder.identifier}`const[targetEvent]=events.filter(e=>e.notes!=null&&e.notes.includes(targetNote))//過(guò)濾重復(fù)的reminderif(!m_dict[reminder.calendar.title]){console.warn("找不到日歷"+reminder.calendar.title)continue}if(targetEvent){//console.log(`找到已經(jīng)創(chuàng)建的事項(xiàng)${reminder.title}`)updateEvent(targetEvent,reminder)}else{console.warn(`創(chuàng)建事項(xiàng)${reminder.title}到${reminder.calendar.title}`)constnewEvent=newCalendarEvent()newEvent.notes=targetNote+"\n"+reminder.notes//要加入備注updateEvent(newEvent,reminder)}}Script.complete()functionupdateEvent(event,reminder){event.title=`${reminder.title}`cal_name=reminder.calendar.titlecal=m_dict[cal_name]event.calendar=cal//console.warn(event.calendar.title)//已完成事項(xiàng)if(reminder.isCompleted){event.title=`?${reminder.title}`event.isAllDay=trueevent.startDate=reminder.dueDateevent.endDate=reminder.dueDate//varending=newDate(reminder.completionDate)//ending.setHours(ending.getHours()+1)//event.endDate=endingvarperiod=(reminder.dueDate-reminder.completionDate)/1000/3600/24period=period.toFixed(1)if(period<0){period=-periodevent.location="延期"+period+"天完成"}elseif(period==0){event.location="準(zhǔn)時(shí)完成"}else{event.location="提前"+period+"天完成"}}//未完成事項(xiàng)else{constnowtime=newDate()varperiod=(reminder.dueDate-nowtime)/1000/3600/24period=period.toFixed(1)//console.log(reminder.title+(period))if(period<0){//待辦順延event.location="延期"+(-period)+"天"http://如果不是在同一天,設(shè)置為全天事項(xiàng)if(reminder.dueDate.getDate()!=nowtime.getDate()){event.title=`?${reminder.title}`event.startDate=nowtimeevent.endDate=nowtimeevent.isAllDay=true}//在同一天的保持原來(lái)的時(shí)間else{event.title=`??${reminder.title}`event.isAllDay=falseevent.startDate=reminder.dueDatevarending=newDate(reminder.dueDate)ending.setHours(ending.getHours()+1)event.endDate=ending}console.log(`【${reminder.title}】待辦順延${-period}天`)}else{event.title=`??${reminder.title}`event.isAllDay=falseevent.location="還剩"+period+"天"event.startDate=reminder.dueDatevarending=newDate(reminder.dueDate)ending.setHours(ending.getHours()+1)event.endDate=ending}}if(!reminder.dueDateIncludesTime)event.isAllDay=trueevent.save()}

會(huì)看見(jiàn)“提醒事項(xiàng)同步行事歷”Scripts腳本后,就可以退回主畫(huà)面。

3.建立捷徑自動(dòng)化

開(kāi)啟“捷徑”App,點(diǎn)選“自動(dòng)化”>“制作個(gè)人自動(dòng)化操作”,選擇“App”。

按下“App”按鈕,搜索并且勾選“提醒事項(xiàng)”和“行事歷”。

最后確定自動(dòng)化操作是否設(shè)定為“已開(kāi)啟”,就可以按“下一步”。在動(dòng)作編輯頁(yè)面中,點(diǎn)選“加入動(dòng)作”。

利用搜索找到“Scriptable”,并且從RunScript內(nèi)選擇剛創(chuàng)建的JavaScript自動(dòng)化腳本。

最后點(diǎn)擊“下一步”。

會(huì)進(jìn)入自動(dòng)化執(zhí)行設(shè)定頁(yè)面,將“執(zhí)行前先詢(xún)問(wèn)”和“執(zhí)行時(shí)通知”兩項(xiàng)功能都關(guān)閉,最后點(diǎn)擊“完成”。

4.排除自動(dòng)化錯(cuò)誤

以上步驟就能實(shí)現(xiàn)打開(kāi)內(nèi)建“行事歷”或“提醒事項(xiàng)”App,就會(huì)立即自動(dòng)同步,不過(guò)Sctiptable沒(méi)有設(shè)定好權(quán)限,會(huì)導(dǎo)致執(zhí)行腳本會(huì)出現(xiàn)“找不到日歷錯(cuò)誤”情況,會(huì)發(fā)現(xiàn)兩個(gè)App之間沒(méi)辦法同步,底下告訴大家解決方法。(此步驟一定要做)

先打開(kāi)iOS內(nèi)建“設(shè)定”,找到“Scriptable”控制設(shè)定,將“行事歷”和“提醒事項(xiàng)”關(guān)閉再次開(kāi)啟,偏好語(yǔ)言設(shè)定為“英文”。

都設(shè)定完成后,將iPhone重開(kāi)機(jī)一次,打開(kāi)“Scriptable”App執(zhí)行“提醒事項(xiàng)同步行事歷”腳本,觀(guān)察Log如果沒(méi)有跳出任何黃字錯(cuò)誤,能夠正常運(yùn)行就代表已經(jīng)成功。

5.實(shí)現(xiàn)行事歷與提醒事項(xiàng)同步

以上全部都設(shè)定完成后,后續(xù)只要打開(kāi)“行事歷”或“提醒事項(xiàng)”其中一款A(yù)pp就會(huì)立即同步,只要紀(jì)錄在“提醒事項(xiàng)”App的未完成的代辦事項(xiàng),就會(huì)立即同步到“行事歷”App內(nèi),甚至?xí)@示還剩多少時(shí)間。

要是完成的代辦事項(xiàng),在行事歷內(nèi)也會(huì)看間打勾狀態(tài),透過(guò)行事歷也能清楚知道今天有哪些未完成的工作,不管是日常生活、工作或?qū)W業(yè)都很方便。

要是打開(kāi)行事歷App沒(méi)有出現(xiàn)提醒事項(xiàng)的項(xiàng)目,檢查“提醒事項(xiàng)”內(nèi)是否有設(shè)定日期時(shí)間,或是將行事歷App從后臺(tái)關(guān)閉再次打開(kāi)就可以,當(dāng)然也可以建立好幾組提醒事項(xiàng)列表,只要行事歷有對(duì)應(yīng)的名稱(chēng)兩邊就能夠同步。

如何刪除行事歷內(nèi)的提醒事項(xiàng)項(xiàng)目?

要是有些提醒事項(xiàng)已經(jīng)完成,還是會(huì)一直顯示在iOS行事歷內(nèi)要怎么刪除?這部分要透過(guò)刪除提醒事項(xiàng)的項(xiàng)目才能移除,操作方法如下:

打開(kāi)“提醒事項(xiàng)”App的項(xiàng)目,按下右上角“???”>“顯示已完成的項(xiàng)目”。

列表就會(huì)顯示已經(jīng)完成的代辦事項(xiàng),往左滑動(dòng)選擇“刪除”已經(jīng)完成的事項(xiàng),就能夠?qū)⑿惺職v已完成的項(xiàng)目也移除。

功能總結(jié)

透過(guò)這篇技巧后,就可以讓iPhone行事歷與提醒事項(xiàng)進(jìn)行同步功能,而且免費(fèi)又方便,只要有新增移除和編輯動(dòng)作,一切透過(guò)提醒事項(xiàng)內(nèi)操作就可以,行事歷只是單純顯示。

標(biāo)簽列表

Copyright ? 2017-2023 baojinkeji.com

寶金科技 版權(quán)所有