configureAppNotificationInjection function

Future<void> configureAppNotificationInjection(
  1. AppEnvironment environment,
  2. AppNotificationConfig config
)

Implementation

Future<void> configureAppNotificationInjection(
  AppEnvironment environment,
  AppNotificationConfig config,
) async {
  if (!getItNotifications.isRegistered<AppNotificationConfig>()) {
    getItNotifications.registerSingleton<AppNotificationConfig>(config);
  }

  getItNotifications.registerSingletonAsync<NotificationService>(
    () async {
      return NotificationServiceImpl(
        httpClient: getItNotifications(),
        notificationConfig: config,
      );
    },
    dependsOn: [
      if (AppEnvironment.test != environment) IHttpClient,
    ],
  );

  await getItNotifications.isReady<NotificationService>();
}