I am using flutter android alarm manager plus and awesome notification package to get notifications periodically. It's working perfectly in the emulator but when I am generating an apk file and installing the app in a real android device through that apk file it's not showing any notification. So, could anyone please help me share your precious experience? Thanks in advance! Here you go with my code -
Future<void> notify() async {
try {
AwesomeNotifications().createNotification(
content: NotificationContent(
id: 1,
channelKey: 'basic_notification',
title: 'TestApp',
body: 'Trial local notification in background',
));
} catch (e) {
print(e.toString());
}
}
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await AndroidAlarmManager.initialize();
await AwesomeNotifications().initialize(
'resource://drawable/app_icon',
[
NotificationChannel(
channelKey: 'basic_notification',
channelName: 'FitJerk Motivation',
channelDescription: "FitJerk Today Notification ",
defaultColor: Colors.blue,
importance: NotificationImportance.High,
ledColor: Colors.white,
playSound: true,
enableLights: true,
enableVibration: true
)
]);
await AndroidAlarmManager.periodic(const Duration(minutes: 1), 1, notify,
startAt: DateTime(DateTime.now().year, DateTime.now().month, DateTime.now().day, 8, 30),
exact: true, wakeup: true, allowWhileIdle: true, rescheduleOnReboot: true);
runApp(const MyApp());
}