NativeScript / NativeScript/plugins
[@nativescript/local-notifications] Schedule not work on iOS with Buddhist calendar
還沒有人認領這個 Issue。
- 主要語言
- TypeScript
- 星號
- 206
- 分支
- 123
- 平均合併
- 2 天 1 小時
- 30 天內合併 PR
- 1
描述
Dear sir,
I had upgraded my app to NativeScript 7 and the notification (@nativescript/local-notifications, version 5.1.0) does not work on iOS (14.4). After debugging all day, I found that LocalNotifications.schedule() not work because my iPhone is set the calendar to Buddhist.
The bug is in the index.ios.js file, in the method schedulePendingNotificationsNew() of class LocalNotificationsImpl as part of code below:
// Notification trigger and repeat
let trigger;
if (options.at) {
const cal = NSCalendar.currentCalendar; //LocalNotificationsImpl.calendarWithMondayAsFirstDay();
const date = cal.componentsFromDate(LocalNotificationsImpl.getInterval(options.interval), options.at);
date.timeZone = NSTimeZone.defaultTimeZone;
trigger = UNCalendarNotificationTrigger.triggerWithDateMatchingComponentsRepeats(date, options.interval !== undefined);
}
else {
trigger = UNTimeIntervalNotificationTrigger.triggerWithTimeIntervalRepeats(2, false);
}
At the line 137, the LocalNotificationsImpl.calendarWithMondayAsFirstDay() which return ISO8601 (Gregorian) calendar make a wrong matching trigger. So, I change the code to use the NSCalendar.currentCalendar and It work well.
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 index.ios.js 中的 LocalNotificationsImpl.schedulePendingNotificationsNew() 開始,接著檢查 calendarWithMondayAsFirstDay() 以及報告中所示的 trigger 建構方式。在啟用佛教曆法的 iOS 14.4 上重現,並驗證 schedule() 能建立正常運作的通知,同時保留現有的重複行為。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- ios, javascript, typescript
- 領域
- mobile-dev
- Issue 類型
- 缺陷
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 52/100