NativeScript / NativeScript/plugins
[@nativescript/local-notifications] Scheduling a notification using the "at" property results in the notification being severly late
まだ誰も着手していません。
- 主要言語
- TypeScript
- スター
- 206
- フォーク
- 123
- 平均マージ
- 2日 1時間
- マージ済み PR(30日)
- 1
説明
- Android 13, targeting API level 33
- @nativescript/core 8.5.7
- @nativescript/local-notifications 6.1.1
This has not been tested on iOS yet, but will be soon, and I'll update this issue with the results once that has been done. It has been replicated on both a Samsung phone and tablet.
While trying to make use of the LocalNotifications.schedule() functionality, the notification arrives as expected, but ends up being significantly late. For instance, when trying to schedule a notification a minute into the future:
public async addScheduledNotification(notificationId: string) {
const notification = NOTIFICATION_TYPES.find((n => n.id == notificationId));
const targetStart = new Date(new Date().getTime() + 60 * 1000);
console.log(`target start: ${targetStart}`);
console.log(`getTime: ${targetStart.getTime()}`);
console.log(await LocalNotifications.schedule([{
id: Number.parseInt(notification.id),
title: 'My App',
body: notification.body,
// interval: 'day' as ScheduleInterval,
channel: 'MyApp',
priority: 2,
at: targetStart
}]));
console.log(await LocalNotifications.getScheduledIds());
}
Output:
JS: CONSOLE LOG: target start: Tue Sep 05 2023 21:30:00 GMT-0400 (EDT)
JS: CONSOLE LOG: getTime: 1693963800000
JS: CONSOLE LOG: [0]
JS: CONSOLE LOG: [0]
the notification will arrive about 1 minute and forty five seconds from the time the code runs. I've tried different use cases and the delay can be as large as 15 minutes to an hour. Lowering the delay to ten seconds after the code runs results in it arriving on time. Leaving the at parameter out results in the notification being shown immediately as expected. There doesn't seem to be much of a difference whether the screen is on or off when the notification is supposed to fire. Seeing as the screen is often on and there's still a delay, I don't suspect the issue is due to a battery saver or Doze.
From my reading of the Android documentation and this plugin's source code, exact alarms are being used with RTC_WAKEUP so there shouldn't be much of a delay in the showing of the notification.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された JavaScript/TypeScript のスケジュール例を使用し、@nativescript/core 8.5.7 と @nativescript/local-notifications 6.1.1 を使って Android 13 で遅延を再現します。報告されたデバイス全体で、要求した at 時刻と実際の配信時刻を比較します。短い間隔と長い間隔で動作を検証し、スケジューリングの遅延を特定して修正できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- android, javascript, typescript
- 領域
- mobile-dev
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 28/100