initialize method

Future initialize (
  1. {@required String forgroundIconName,
  2. @required String androidChannelId,
  3. @required String androidChannelName,
  4. @required String androidChannelDescription,
  5. String translateMessage(
    1. String key,
    2. List<String> args
    )}
)

Implementation

static Future initialize({
  @required String forgroundIconName,
  @required String androidChannelId,
  @required String androidChannelName,
  @required String androidChannelDescription,
  String Function(String key, List<String> args) translateMessage,
}) async {
  WidgetsFlutterBinding.ensureInitialized();
  _androidChannelId = androidChannelId;
  _androidChannelName = androidChannelName;
  _androidChannelDescription = androidChannelDescription;
  _translateMessage = translateMessage;

  _firebaseMessaging.configure(
    onMessage: _onForgroundNotification,
    onLaunch: _onNotificationLaunch,
    onResume: _onResume,
  );
  _iOSPermission();
  var initializationSettingsAndroid =
      AndroidInitializationSettings(forgroundIconName);
  var initializationSettingsIOS = IOSInitializationSettings();
  var initializationSettings = InitializationSettings(
      android: initializationSettingsAndroid, iOS: initializationSettingsIOS);
  _localeNotification.initialize(initializationSettings,
      onSelectNotification: _onSelectLocaleNotification);
  var luanchDetails =
      await _localeNotification.getNotificationAppLaunchDetails();
  if (luanchDetails != null &&
      _luanchedNotification == null &&
      luanchDetails.didNotificationLaunchApp &&
      luanchDetails.payload != null) {
    _luanchedNotification = FCMNotification.fromJson(
        jsonDecode(luanchDetails.payload), _translateMessage);
  }
}