Route reminder notification taps into app UI
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:relationship_saver/features/local/local_models.dart';
|
||||
import 'package:relationship_saver/features/reminders/scheduling/reminder_notification_intent_bus.dart';
|
||||
import 'package:relationship_saver/features/reminders/scheduling/reminder_scheduler.dart';
|
||||
import 'package:timezone/timezone.dart' as tz;
|
||||
|
||||
@@ -14,7 +15,10 @@ class LocalNotificationsReminderScheduler implements ReminderScheduler {
|
||||
LocalNotificationsReminderScheduler({
|
||||
ReminderNotificationsDriver? driver,
|
||||
DateTime Function()? now,
|
||||
}) : _driver = driver ?? FlutterReminderNotificationsDriver(),
|
||||
ReminderNotificationIntentBus? intentBus,
|
||||
}) : _driver =
|
||||
driver ??
|
||||
FlutterReminderNotificationsDriver(onTapPayload: intentBus?.emitTap),
|
||||
_now = now ?? DateTime.now;
|
||||
|
||||
final ReminderNotificationsDriver _driver;
|
||||
@@ -122,10 +126,14 @@ abstract class ReminderNotificationsDriver {
|
||||
|
||||
class FlutterReminderNotificationsDriver
|
||||
implements ReminderNotificationsDriver {
|
||||
FlutterReminderNotificationsDriver({FlutterLocalNotificationsPlugin? plugin})
|
||||
: _plugin = plugin ?? FlutterLocalNotificationsPlugin();
|
||||
FlutterReminderNotificationsDriver({
|
||||
FlutterLocalNotificationsPlugin? plugin,
|
||||
void Function(String payload)? onTapPayload,
|
||||
}) : _plugin = plugin ?? FlutterLocalNotificationsPlugin(),
|
||||
_onTapPayload = onTapPayload;
|
||||
|
||||
final FlutterLocalNotificationsPlugin _plugin;
|
||||
final void Function(String payload)? _onTapPayload;
|
||||
Future<void>? _initializeFuture;
|
||||
|
||||
@override
|
||||
@@ -204,6 +212,13 @@ class FlutterReminderNotificationsDriver
|
||||
guid: 'ee23c0af-5898-4d96-b599-cf2d7d0d37d7',
|
||||
),
|
||||
),
|
||||
onDidReceiveNotificationResponse: (NotificationResponse response) {
|
||||
final String? payload = response.payload;
|
||||
if (payload == null || payload.isEmpty) {
|
||||
return;
|
||||
}
|
||||
_onTapPayload?.call(payload);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user