NativeScript / NativeScript/plugins

[@nativescript/local-notifications] Schedule not work on iOS with Buddhist calendar

Aperta
#87 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
TypeScript
Stelle
206
Fork
123
Merge medio
2g 1h
PR unite (30g)
1

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia in index.ios.js da LocalNotificationsImpl.schedulePendingNotificationsNew(), quindi esamina calendarWithMondayAsFirstDay() e la costruzione del trigger mostrata nel report. Riproduci il problema su iOS 14.4 con il calendario buddhista abilitato e verifica che schedule() crei una notifica funzionante mantenendo il comportamento di ripetizione esistente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
ios, javascript, typescript
Ambito
mobile-dev
Tipo di issue
Bug
Difficoltà
2/5
Tempo stimato
1-3 ore
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
52/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.