send method
Send the push notification
Implementation
Future<void> send({
DateTime? at,
AndroidScheduleMode? androidScheduleMode,
}) async {
if (kIsWeb) {
throw Exception("Push notifications are not supported on the web");
}
await _requestPermissions();
_sendAt = at;
if (_initialized == false) {
_initialized = await JetNotifications.initialize();
}
NotificationDetails notificationDetails = await _getNotificationDetails();
if (_sendAt != null) {
String sendAtDateTime = at!.toString();
JetLogger.info("Scheduling notification for: $sendAtDateTime");
final scheduledTime = tz.TZDateTime.parse(tz.local, sendAtDateTime);
JetLogger.info("Parsed scheduled time: $scheduledTime");
await _localNotifications.zonedSchedule(
_id ?? 1,
_title,
_body,
scheduledTime,
notificationDetails,
androidScheduleMode:
androidScheduleMode ?? AndroidScheduleMode.exactAllowWhileIdle,
payload: _payload,
);
JetLogger.info("Notification scheduled successfully");
return;
}
await _localNotifications.show(
_id ?? 1,
_title,
_body,
notificationDetails,
payload: _payload,
);
}