I'm building an app that allows users to call eachother using the agora_rtc_engine. I'm currently stuck trying to implement a notification system that will alert users when they receive a call.
I'm using Firebase Messaging for notifications.
I have the following questions:
How would I go about replacing the default notification card with a custom one that has buttons for answering or declining the call?
How can I specify the amount of time the notification stays on screen? An incoming call rings for about 30 seconds before closing, so I would like my notification card to appear on screen for that period of time.
I've been looking at the flutter_local_notifications, but they don't have a "incoming call" notification style.
Any piece of information is highly appreciated. Thank you!
Displaying a notification in Flutter To display a notification, we need to create a platform-specific NotificationDetails instance, which takes in arguments that are unique to each platform. AndroidNotificationDetails handles the configuration of notifications in Android devices.
I suggest you trying to use Firebase Cloud Messaging.
Check out the "Setting the lifespan of a message" section of the official documentation: https://firebase.google.com/docs/cloud-messaging/concept-options#ttl
There you will find an example of a cloud message with time_to_live parameter - it determines how long will the notification be active on the recipient's device.
Here is an example of a request that includes TTL (taken from the official documentation):
{
"message":{
"token":"bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
"data":{
"Nick" : "Mario",
"body" : "great match!",
"Room" : "PortugalVSDenmark"
},
"apns":{
"headers":{
"apns-expiration":"1604750400"
}
},
"android":{
"ttl":"4500s"
},
"webpush":{
"headers":{
"TTL":"4500"
}
}
}
}
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