#FidelitasUniversity
I developed a custom action that allows local push notifications to be made directly from the project without using services external to the app.
This is the dependency that is used to do this.
This is the code, it is important to note that the messages can be changed in the await flutterLocalNotificationsPlugin.show at the end by changing what is inside the ' '
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
Future newCustomAction() async {
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
FlutterLocalNotificationsPlugin();
var initializationSettingsAndroid =
AndroidInitializationSettings('@mipmap/ic_launcher');
var initializationSettingsIOS = DarwinInitializationSettings();
var initializationSettings = InitializationSettings(
android: initializationSettingsAndroid, iOS: initializationSettingsIOS);
await flutterLocalNotificationsPlugin.initialize(initializationSettings);
var androidPlatformChannelSpecifics = AndroidNotificationDetails(
'random_channel_id', 'channel_name',
channelDescription: 'channel_description',
importance: Importance.max,
priority: Priority.high,
ticker: 'ticker');
var iOSPlatformChannelSpecifics = DarwinNotificationDetails();
var platformChannelSpecifics = NotificationDetails(
android: androidPlatformChannelSpecifics,
iOS: iOSPlatformChannelSpecifics);
await flutterLocalNotificationsPlugin.show(0, 'Test NotificaciΓ³n',
'Esto es un test de push notification', platformChannelSpecifics,
payload: 'test');
}
In this way the action is added to the button.
And this is how the custom code would look like working correctly.