init method

Future<void> init({
  1. required String appName,
  2. required String projectId,
  3. required String firebaseCurrentApiKey,
  4. required String firebaseMobileSdkAppId,
  5. required String firebaseStorageBucket,
  6. String? firebaseUrl,
  7. required String firebaseProjectNumber,
  8. required dynamic notificationDataCallback(
    1. Map<String, String?>
    )?,
})

used to initialise the SDK and Firebase

  • Note: All the required paramters can be found in google-services.json file downloaded from Firebase console except appName which can be any String notificationDataCallback all notification payload data will be passed to the calling app if this is not null

Implementation

Future<void> init({
  required String appName,
  required String projectId,
  required String firebaseCurrentApiKey,
  required String firebaseMobileSdkAppId,
  required String firebaseStorageBucket,
  String? firebaseUrl,
  required String firebaseProjectNumber,
  required Function(Map<String, String?>)? notificationDataCallback,
}) async {
  Logs.d('started init');
  await _initialiseApp(_getFirebaseModel(
    appName,
    projectId,
    firebaseCurrentApiKey,
    firebaseMobileSdkAppId,
    firebaseStorageBucket,
    firebaseUrl,
    firebaseProjectNumber,
  ));
  FeedSDK.appName = appName;
  Logs.d('ended init');

  if (Platform.isIOS) {
    _requestPermissionForIos();
  }
  FeedApiManager.getInstance().register(_appPreferences);
  _initialiseNotifications(notificationDataCallback);
  _addMessageListener();
}