initializeNotifications method

Future<void> initializeNotifications({
  1. required String appId,
  2. String? channelName,
})

Initialize push notifications.

Implementation

Future<void> initializeNotifications({
  required String appId,
  String? channelName,
}) async {
  if (!await hasNotificationPermission()) {
    await requestNotificationPermission();
  }

  await _initializeFirebaseMessaging();
  await registerDeviceToken(appId);

  _setForegroundMessageHandler();
  _setNotificationOpenAppHandler();
}