0

In my flutter app, I am storing a list of quotes locally with SQFlite database. I want to create a scheduled local notification to display a different quote every day without opening the app (the quote to display should update in the background). Please suggest a way to implement this.

AliZ.ece
  • 51
  • 5

1 Answers1

1

I couldn't use a background execution plugin (like the work manager plugin) to make it working with the flutter_local_notifications plugin.

So, following this issue, I forked the local_notifications repository and customized it for my special use case. I saved the quote id with SharedPreferences on the Dart side and I write a custom function with native code for android to update this id every time the notification is displayed with the native SharedPreferences package for android (following this). Also, I read the quote with this id from the local SQL database (that is created on the Dart side) with the android native SQLite libraries. I didn't implement the ios part since my app isn't intended to work for ios yet.

After that, I commit the changes and pushed it to github and added this line to my flutter project dependencies:

  dependencies:
    git:
      url: git://github.com/team324/flutter_local_notifications.git
      path: flutter_local_notifications/

so I can make further changes and update the repository on github and write

flutter pub upgrade

in the terminal to update the local customized plugin.

AliZ.ece
  • 51
  • 5