feat: 实现日历提醒 in-app fallback 机制及通知服务重构
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'core/constants/app_constants.dart';
|
||||
import 'core/di/injection.dart';
|
||||
import 'core/notifications/local_notification_service.dart';
|
||||
import 'core/notifications/reminder_notification_callbacks.dart';
|
||||
import 'core/router/app_router.dart';
|
||||
import 'core/startup/auth_session_bootstrapper.dart';
|
||||
import 'core/theme/app_theme.dart';
|
||||
@@ -14,12 +15,18 @@ import 'features/auth/presentation/bloc/auth_event.dart';
|
||||
import 'features/auth/presentation/bloc/auth_state.dart';
|
||||
import 'features/calendar/data/services/calendar_service.dart';
|
||||
import 'features/calendar/reminders/reminder_action_executor.dart';
|
||||
import 'features/calendar/reminders/ui/reminder_foreground_presenter.dart';
|
||||
import 'features/chat/presentation/bloc/chat_bloc.dart';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await configureDependencies();
|
||||
await AppConstants.init();
|
||||
final rootNavigatorKey = GlobalKey<NavigatorState>();
|
||||
final reminderForegroundPresenter = ReminderForegroundPresenter(
|
||||
navigatorKey: rootNavigatorKey,
|
||||
executor: sl<ReminderActionExecutor>(),
|
||||
);
|
||||
sl<LocalNotificationService>().bindActionHandler(({
|
||||
required action,
|
||||
required payload,
|
||||
@@ -29,6 +36,9 @@ void main() async {
|
||||
payload: payload,
|
||||
);
|
||||
});
|
||||
sl<LocalNotificationService>().bindInAppReminderHandler(
|
||||
reminderForegroundPresenter.present,
|
||||
);
|
||||
await sl<LocalNotificationService>().initialize();
|
||||
|
||||
final authBloc = sl<AuthBloc>();
|
||||
@@ -37,6 +47,7 @@ void main() async {
|
||||
runApp(
|
||||
LinksyApp(
|
||||
authBloc: authBloc,
|
||||
rootNavigatorKey: rootNavigatorKey,
|
||||
sessionBootstrapper: AuthSessionBootstrapper(
|
||||
calendarService: sl<CalendarService>(),
|
||||
notificationService: sl<LocalNotificationService>(),
|
||||
@@ -44,15 +55,25 @@ void main() async {
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
unawaited(
|
||||
ReminderNotificationCallbacks.bindResponseHandler(
|
||||
sl<LocalNotificationService>().handleNotificationResponse,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
class LinksyApp extends StatelessWidget {
|
||||
final AuthBloc authBloc;
|
||||
final GlobalKey<NavigatorState> rootNavigatorKey;
|
||||
final AuthSessionBootstrapper sessionBootstrapper;
|
||||
|
||||
const LinksyApp({
|
||||
super.key,
|
||||
required this.authBloc,
|
||||
required this.rootNavigatorKey,
|
||||
required this.sessionBootstrapper,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user