Kewal Shah
Kewal Shah

Reputation: 1260

DailyNotificationTrigger in expo-notifications not working on Android device

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.

Upvotes: 5

Views: 4236

Answers (3)

Joey Drab
Joey Drab

Reputation: 11

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.

Upvotes: 1

Hunnain
Hunnain

Reputation: 134

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 
    }
})

Upvotes: 8

Jake Armendariz
Jake Armendariz

Reputation: 177

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

Upvotes: -1

Related Questions