I have developed a dart/flutter app, its function is as a medication reminder app connected with supabase. I have trouble in setting reminder notification on the device installed on phone sdk.
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (9)
Hi I would like to contribute, please use the below snippet.
// initialise the plugin. app_icon needs to be a added as a drawable resource to the Android head project
const AndroidInitializationSettings initializationSettingsAndroid =
AndroidInitializationSettings('app_icon');
final DarwinInitializationSettings initializationSettingsDarwin =
DarwinInitializationSettings(
onDidReceiveLocalNotification: onDidReceiveLocalNotification);
final LinuxInitializationSettings initializationSettingsLinux =
LinuxInitializationSettings(
defaultActionName: 'Open notification');
final InitializationSettings initializationSettings = InitializationSettings(
android: initializationSettingsAndroid,
iOS: initializationSettingsDarwin,
linux: initializationSettingsLinux);
flutterLocalNotificationsPlugin.initialize(initializationSettings,
onDidReceiveNotificationResponse: onDidReceiveNotificationResponse);
...
void onDidReceiveLocalNotification(
int id, String? title, String? body, String? payload) async {
// display a dialog with the notification details, tap ok to go to another page
showDialog(
context: context,
builder: (BuildContext context) => CupertinoAlertDialog(
title: Text(title??''),
content: Text(body??''),
actions: [
CupertinoDialogAction(
isDefaultAction: true,
child: Text('Ok'),
onPressed: () async {
Navigator.of(context, rootNavigator: true).pop();
await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SecondScreen(payload),
),
);
},
)
],
),
);
}
This is the error on your code, exception dosent compile.
Is this via emulator or physical device.
If this is on apk, chances are it would not be able to render due to lack of permission
Hi Gagandeep, the notification work when running the code. But when exported as .apk it does not function. All the permission to read data and allow notification access is given but it is not working.
Just for reference, the app is connected to supabase for Backend along with modular ui. Functions include:
If there is a way to override the action on the call function from db by triggering any SQL entity?
or
Any other ways on local state variable on the app level widget?
Thanks in advance.
ok 2 thing,
If using Backend database, the notification won't work as the apk is not installed through verified means. Hence the OS rejects and. blocks the API request.
If using as apk, I would suggest you remove all features which you have mentioned and use the app state to save the reminder, which is something that ii would not recommend as it becomes a useless app.
But since it is a reminder app, you can use 3rd part reminder services such as sending mail, messages.
Ex. OneSignal.
If you want, their website has a free promo code which you can use. But it have limited usability.
Also, try scrolling through other communities for some solution.
Just trying to help, But I also do have promo codes for onSignal, DM for information
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
flutterLocalNotificationsPlugin.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>().requestNotificationsPermission();
Add single use within function. It should work in emulator
Hi ryver, the suggested code snippet after defining class function it still does not show the reminder. The installed dependencies have been installed but yet the same continues.
On the other hand the language translation does not seem to work.
Any suggestion?