DailyNotificationTrigger in expo-notifications not working on Android device

Viewed 2308

I am trying to implement notifications in an Expo app using expo-notifications. My trigger object in scheduleNotificationAsync conforms to the DailyNotificationTrigger interface, still I'm getting this error:

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

This 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: 8,
    minute: 0,
  },
})

My target device is an emulator running on Android 10. Please help me identify and fix the problem.

3 Answers

Got my hint from interface DailyTriggerInput. Working code should be like following:

Notifications.scheduleNotificationAsync({
    content: { 
        title: 'Winter is coming!' 
    }, 
    trigger: { 
        hour: 18, minute: 36, repeats: true 
    }
})

It's not about Daily trigger. Mistake is in a Expo Documentation. It says nothing about Android which not supports calendar. It taken 3 days to me to solve this issue.

So for the next generations, don't use days, hours and minutes in trigger (on Android platform). Just seconds work properly.

Notifications don't work on emulators. You have to run it on your a physical device for notifications to work

Related