I’m messing with local notifications and am trying to create scheduled ones. I get no errors but the notifications never happen . What’s the best way to debug these? I’ve stepped thru all the code and nothing throws an error message
--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/CAFmLuy6DVMs%2BOvkFRhOB1cLv8VtA4XZx925c4f5AMK%3DM8yN-wg%40mail.gmail.com.
I’m messing with local notifications and am trying to create scheduled ones. I get no errors but the notifications never happen . What’s the best way to debug these? I’ve stepped thru all the code and nothing throws an error message
--
Here is the code. I had to fix sound and launcher_icon errors, at this point nothing throws an error but no notifications come thru so im assuming im missing something config wise but I have looked in the android manifest file and pub and have mirrored everything in the working demo.
SCHEDULE NOTIFICATION CODE
Future<void> scheduleNotification(Medicine medicine) async {
var hour = int.parse(medicine.startTime[0] + medicine.startTime[1]);
var ogValue = hour;
var minute = int.parse(medicine.startTime[2] + medicine.startTime[3]);
var androidPlatformChannelSpecifics = AndroidNotificationDetails(
'repeatDailyAtTime channel id',
'repeatDailyAtTime channel name',
'repeatDailyAtTime description',
importance: Importance.Max,
sound: 'sound',
ledColor: Color(0xFF3EB16F),
ledOffMs: 1000,
ledOnMs: 1000,
enableLights: true,
);
var iOSPlatformChannelSpecifics = IOSNotificationDetails();
var platformChannelSpecifics = NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
for (int i = 0; i < (24 / medicine.interval).floor(); i++) {
if ((hour + (medicine.interval * i) > 23)) {
hour = hour + (medicine.interval * i) - 24;
} else {
hour = hour + (medicine.interval * i);
}
await flutterLocalNotificationsPlugin.showDailyAtTime(
int.parse(medicine.notificationIDs[i]),
'Medication Reminder: ${medicine.medicineName}',
medicine.medicineType.toString() != MedicineType.None.toString()
? 'It is time to take your ${medicine.medicineType.toLowerCase()}, according to schedule'
: 'It is time to take your medicine, according to schedule',
Time(hour, minute, 0),
platformChannelSpecifics);
hour = ogValue;
}
//await flutterLocalNotificationsPlugin.cancelAll();
}
}
PUBSPEC Dependencies
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
rxdart: ^0.22.0
provider: ^3.0.0+1
shared_preferences: 0.5.2
flutter_local_notifications:
flare_flutter:
git:
url: git://github.com/2d-inc/Flare-Flutter.git
ref: dev
path: flare_flutter
dev_dependencies:
flutter_test:
sdk: flutter
flutter_redux: ^0.5.2
snaplist: ^0.1.3
font_awesome_flutter: ^8.0.1
http: ^0.12.0
intl: ^0.15.7
device_calendar: ^0.0.7
dynamic_theme:
eva_icons_flutter:
flutter_speed_dial:
sqflite:
url_launcher: ^5.0.3
swipedetector: ^1.2.0
contacts_service: ^0.2.1
agora_rtc_engine: 0.9.4
permission_handler: ^3.0.0
validators: ^2.0.0
path_provider: ^1.1.0
share_extend: ^1.0.9
shimmer: ^1.0.0
flutter_launcher_icons: "^0.7.2"
flutter_icons:
android: "launcher_icon"
ios: false
image_path: "assets/logo/Mediminder_Logo.png"
ANDROID manifest
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
Sent from Mail for Windows 10
await flutterLocalNotification” give you? Does it show the notifications you have scheduled?Also, have you added<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"></action>
</intent-filter>
</receiver>
and <receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
Thank you AndyTomG! That fixed it, I was missing the Android manifest receiver settings.
Im new to flutter and setting up notifications, do these notifications work when the app is NOT running as well?
I also need to set up push notifications for my app do you have a preference on what to use for those?
Thanks,
Sam
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/5d64305f.1c69fb81.54486.29b2%40mx.google.com.