Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for timestamp trigger notifications across timezones #1033

Open
samueljamesbell opened this issue May 5, 2024 · 0 comments
Open

Comments

@samueljamesbell
Copy link

Hello! Just want to start by saying how much I love notifee - you guys are doing a great job!

In our production app, we're seeing reports of notifications not arriving at correct times when the user has changed timezone. We're making extensive use of TimestampTrigger in order to set notifications at a particular point in the future in terms of milliseconds since the (UTC) epoch.

Here's an example of what we're seeing:

  1. Notification created at 13:00 GMT (+00:00), with trigger set for 20:00 GMT, i.e. 7 hours in the future
  2. User changes timezone, e.g. to CET (+01:00)
  3. Notification arrives at 20:00 CET (i.e. 19:00 GMT), rather than 19:00 CET (i.e. 20:00 GMT), i.e. only 6 hours after the creation time

Given that TimestampTrigger accepts a timestamp argument in terms of milliseconds since the epoch, this isn't what I was expecting.

I have had a dig through the notifee source, and it seems that, on iOS at least, TimestampTrigger ultimately relies on matching DateComponents, rather than a milliseconds since epoch trigger (see here). It also looks like UNCalendarNotificationTrigger could potentially accept a DateComponents with a timezone attached.

Here's how we're scheduling, for reference:

let notification: Notification = {
  title,
  body,
  ...
};

let trigger: TimestampTrigger = {
  type: TriggerType.TIMESTAMP,
  timestamp: timestampInMillisSinceEpochUTC,
  alarmManager: {
    allowWhileIdle: true,
  },
};

return await notifee.createTriggerNotification(notification, trigger);

Would be great to understand if I'm missing something here. Does notifee have support for notifications that are fixed to a UTC time, rather than vary with the user's current timezone?

Thanks in advance for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant