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.
Along with the expo-notifications module, which provides all the client-side functionality for push notifications, Expo can also handle sending these notifications off to APNs and FCM for you! All you need to do is send the request to our servers with the ExpoPushToken you grabbed in the last step.
To use it, go to Expo's push notifications tool, add the Expo push token from your app, fulfil the message fields and send the notification.
The ExpoPushToken will never "expire" but if one of your users uninstalls the app, you'll receive a DeviceNotRegistered error back from Expo's servers, meaning you should stop sending notifications to this app.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With