John N Blanchard
Flutter: Local Notifications
Updated: Feb 26, 2019
Apps are great at gripping the attention of users. On iOS there are five app-states; and developers are able to create experiences using the current context. If an app is in the background, the developer could opt to fetch some data for the next time the user enters the foreground. Because notifications are held by the device and are outside of the app sandbox; it allows developers to talk to the user even while an app is out of the foreground.
One thing to get out of the way will be the two types of notifications, there are remote notifications; often called push notifications. And there are local notifications that are not received through APN but rather scheduled by the developer on device. Local notifications are created by the device while push notifications are created by some server.
With Flutter, there exists a wonderful package for doing local notifications cross platform. I am familiar with iOS notification programming, but when it came to choosing my Android channel ID; I was confused for a bit. This package cleared up all my uncertainties, and allowed access to scheduling local notifications..
In my program there exists trains showing their departure times. If you tap on a departure, I schedule a notification one minute prior to the train leaving. Note that this function is async, it waits for the user to accept permission. With the above implementation, the user is prompted for notification permission after tapping a button.