expo: [Unhandled promise rejection: Error: Failed to schedule the notification. Trigger of type: calendar is not supported on Android.]

πŸ› DailyNotificationTrigger in expo-notifications not working on Android device

Summary of Issue

My trigger object in scheduleNotificationAsync conforms to the DailyNotificationTrigger interface as shown in the documentation yet I’m getting this error: [Unhandled promise rejection: Error: Failed to schedule the notification. Trigger of type: calendar is not supported on Android.]

Below is the snippet of code that produces the error:

Notifications.scheduleNotificationAsync({
  content: {
    title: 'Complete a quiz',
    body: "πŸ‘‹ Don't forget solve a quiz today!",
  },
  trigger: {
    type: 'daily',
    hour: 15,
    minute: 42,
  },
})

Environment

  Expo CLI 3.21.12 environment info:
    System:
      OS: macOS 10.15.5
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 12.16.2 - /usr/local/bin/node
      Yarn: 1.22.4 - /usr/local/bin/yarn
      npm: 6.14.4 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    IDEs:
      Android Studio: 4.0 AI-193.6911.18.40.6514223
      Xcode: 11.5/11E608c - /usr/bin/xcodebuild
    npmPackages:
      expo: ^38.0.0 => 38.0.3 
      react: 16.11.0 => 16.11.0 
      react-dom: 16.11.0 => 16.11.0 
      react-native: https://github.com/expo/react-native/archive/sdk-38.0.0.tar.gz => 0.62.2 
      react-native-web: ~0.11.7 => 0.11.7 
    npmGlobalPackages:
      expo-cli: 3.21.12

Target Platform: Android 10

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (1 by maintainers)

Most upvoted comments

Is there any reason why this sizeable bug has just been left with no answer?

The documentation of Notifications needs to be improved. Please provide more snacks for scheduling notifications. I love Expo and it has made development much easier than native Android but better documentation would go the extra mile

is there any way to create a schedule notification base in a future date but compatible with ios and android?

Ok, then my question is why has this sizeable bug been closed with no answer or resolution?

Hi @walkeknow! Thanks for your issue report. The notifications module is a big one and the documentation isn’t always crystal clear, for that I’m sorry. To schedule a local notification, you have to use the NotificationTriggerInput instead of the NotificationTrigger. If you check the input type for a DailyTriggerInput, you have to supply these properties:

export interface DailyTriggerInput {
  hour: number;
  minute: number;
  repeats: true;
}

So, for you the example you provided, that would be:

{
  hour: 15,
  minute: 42,
  repeats: true,
},

Hope it helps!

so no solution to this up to now? the hour and minute trigger is still not working on android

Yeah, I also need this fix to be implemented on Android.

Notifications.scheduleNotificationAsync({ content: { title: title, body: text, data: { url: screen } }, trigger: { seconds: secondsNearest } });

You can pass the trigger in seconds