sendNotification function
Implementation
Future<void> sendNotification(String notificationType) async {
print("SENDING NOTIFICATION FOR *$notificationType*");
late AndroidNotificationDetails androidDetails;
String title;
String message;
switch (notificationType) {
case "Message Received":
androidDetails = MessageReceived();
title = "New Message";
message = "You have received a new message.";
break;
case "Bitcoin Received":
androidDetails = BitcoinReceived();
title = "Bitcoin Received";
message = "You've received Bitcoin in your wallet.";
break;
case "Bitcoin Sent":
androidDetails = BitcoinSent();
title = "Bitcoin Sent";
message = "Your Bitcoin transaction was successful.";
break;
case "Bitcoin Send Failed":
androidDetails = BitcoinSendFailed();
title = "Transaction Failed";
message = "Your Bitcoin transaction could not be completed.";
break;
case "App Terminated":
androidDetails = AppTerminated();
title = "Stay Connected";
message = "Keep orange running in the background to receive notifications on time.";
break;
default:
androidDetails = MessageReceived();
title = "Notification";
message = "You have a new notification.";
break;
}
var notificationDetails = NotificationDetails(android: androidDetails);
await flutterLocalNotificationsPlugin.show(
DateTime.now().millisecondsSinceEpoch ~/ 1000,
title,
message,
notificationDetails,
payload: 'message_payload',
);
}