I am currently trying to implement a notification from a flutter app using the Awesome Notifications plugin (I am using version ^0.7.2).
My goal is to send a notification after a certain interval such as every month after activation. I have been trying to play around with some code and have not had any success so far.
Here is the function I am currently using to create the Notification.
Future<void> createNotification(
String Name,
int seconds,
int id,
) async {
if (seconds != 0) {
print(seconds);
await AwesomeNotifications().createNotification(
schedule: NotificationInterval(interval: 180, repeats: true),
content: NotificationContent(
id: id,
roundedBigPicture: true,
channelKey: "basic_channel",
title: "Test",
body: "Test,
notificationLayout: NotificationLayout.Default,
displayOnForeground: true,
displayOnBackground: true,
actionType: ActionType.Default));
}
}
The function, is called through an elevated button where the user can activate notifications. A unique ID is generated via DateTime MillisecondSinceEpoch.remainder(1000) and the seconds value is passed in the function call, like so:
onTap: () {
createNotification(mainLocation,
secondsUntilNotification, uniqueId);
},
If run like this, the notification is registered, but fires every second or every few seconds, rather than the declared 180 seconds between notification fires. Interestingly, the notification fires fine after the specified interval when I do not set the repeats tag to true.
I am currently testing on a Xiaomi Mi 11 Lite with Android 11
EDIT : When running this on iPhone everything works fine. So it seems to be an issue with how android is handling the code?
Where are things going wrong?