Closed TJMusiitwa closed 4 years ago
_scheduleNotification
method.notificationSetup
method, you should have something like flutterLocalNotificationsPlugin.initialize(initializationSettings, onSelectNotification: onSelectNotification);
.Hey yes sorry should have updated the code slightly before posting. However, even with the made changes and testing that I did yesterday, all the notifications show up again past their scheduled time each time the app is opened.
I'm on vacation so will keep this brief. The problems you're describing appear to be more of an issue in your code than an issue within the plugin itself (i.e. a bug). As such I'd suggest you post on sites like stack overflow as the issues board here is more for bugs
Okay I understand but if I could please inquire what's the best way to initialise my list of scheduled notifications without having to do a button press as shown in the example file of the package repo? Because admittedly calling it in my unit state is having slight issues for me?
That is something you need to determine as the best solution is one that makes sense in your context. In some cases it'll involve pressing a button and sounds like it doesn't work in your scenario for whatever reason.
Perhaps rather than asking what is the best solution you should try to debug and find out what the real cause of your issue is. At a glance, there are some odd things I see about your code such as not awaiting async method calls, rescheduling the same notifications in initState without checking if that should happen.
Regardless I'll be closing this as the these kinds of problems should be posted on places like stack overflow
Hey there, I made use of the flutter_local_notifications package and it was quick and easy to set up all the required notifications for the app. However, I seem to be running into 2 issues.
Each time the application is opened, after it has been killed, it re-displays all the past scheduled notifications at once, which obviously it shouldn't be doing.
I have not been able to get the notification selected function to work properly where it has defaulted to open the home screen each time as opposed to the "agenda" screen that has been set.
I wonder if the issue to the 1st issue is because I set the notification initialisation in the initState method or something else.
Below is the code covering my notifications set-up `@override void initState() { super.initState(); //checkFirstSeen(); //Check for the first screen to show notificationSetup(); _scheduleNotification();
}
void notificationSetup() { var initializationSettingsAndroid = new AndroidInitializationSettings('transparent_pmi'); var initializationSettingsIOS = new IOSInitializationSettings(); var initializationSettings = new InitializationSettings( initializationSettingsAndroid, initializationSettingsIOS); flutterLocalNotificationsPlugin.initialize(initializationSettings); //flutterLocalNotificationsPlugin.getNotificationAppLaunchDetails().toString(); }
Future onSelectNotification(String payload) async { if (payload != null) { debugPrint('Notification payload: ' + payload); } await Navigator.push( context, MaterialPageRoute(builder: (context) => AgendaPage())); analytics.logAppOpen();
}
Future _scheduleNotification() async {
var androidPlatformChannelSpecifics = AndroidNotificationDetails(
'pmi_conference', 'Agenda Notifications', 'Alert users of session',
style: AndroidNotificationStyle.BigText);
} ` Running Flutter version 1.9.1+hotfix.4 on VS Code. Live testing the app on an Android 9 smartphone