expo: Can't schedule local notification on Android on latest expo client

🐛 Bug Report

Every time a try to schedule a local notification on Android using the latest version of Expo Client (the one ready for SDK 33) it throws an error Invalid time provided. It worked fine before updating the Expo Client.

Environment

  • Android 7.0
  • Expo Client 2.11.0

Steps to Reproduce

try {
  await Notifications.scheduleLocalNotificationAsync(
    {
      title: 'Title',
      body: 'body',
    },
    {
      time: new Date(Date.now() + 10000),
    }
  );
} catch (e) {
  alert(e);
}

Expected Behavior

It should schedule a location notification without throwing an error.

Actual Behavior

It always fails regardless of the date.

Reproducible Demo

https://snack.expo.io/@desenvolvimento.secullum/0ace06

Open this Snack via Expo Client on an Android device and it should alert the error message.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 9
  • Comments: 22 (3 by maintainers)

Most upvoted comments

Reopening because the fix has landed but has not yet been released to the play store. We’re working on it and will update here when it’s released!

I think the problem is because of this change: https://github.com/expo/expo/commit/e01799d18c504186d147bdf089e298145753d2d5#diff-ae8453b34f5c87ce54242f23d4200295

On the SDK, it always convert to Number on Notifications.ts now. But as I’m using SDK 32, it’s not doing that. But the updated Java code (which runs on Expo Client now) expects it to be a Number.

I’ve also tried to use the moment and convert it into Unix ms timestamp. It appears that the issue is on expo notifications module. Few observations:

  • despite the fact that I’m passing correct timestamp for my timezone, I still get UTC time back in the error message with ISO string notation, so it looks like notification is trying to be scheduled for past time
  • scheduling it for 1h+ in the future doesn’t solve the problem, time is still invalid.

Environment Android 9.0 ExpoSDK: 32.0.0 Expo Client 2.18.2

If someone needs a temporary solution: downgrade expo client on your device to 2.10.0

@IElgohary if I build an APK it works ¯\_(ツ)_/¯

I also think that if you use the preview version of SDK 33 (https://blog.expo.io/updated-expo-client-available-on-app-store-and-play-store-8747bd3a1364) it might work, but I haven’t tested it.