initializeNotifications method

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

Initialize push notifications (with default channel for Android).

  • Uses app id as the channel id.

Implementation

Future<void> initializeNotifications({
  required String appId,
  String? channelName,
}) async {
  // Check if the app requires notification permission (Android 13+ or iOS).
  await requestNotificationPermission();

  // Initialize Firebase Messaging
  await _initializeFirebaseMessaging();

  /// Register device token for notifications.
  await registerDeviceToken();

  /// Set foreground message handler
  setForegroundMessageHandler();

  /// Set notification open app handler
  setNotificationOpenAppHandler();
}