initApp static method

Future initApp({
  1. String? applicationId,
  2. String? androidApiKey,
  3. String? iosApiKey,
  4. String? customDomain,
})

This method must be called once before sending the request to the Backendless server. Must be an app ID and API key or custom domain.

Implementation

static Future initApp(
    {String? applicationId,
    String? androidApiKey,
    String? iosApiKey,
    //String? jsApiKey,
    String? customDomain}) async {
  if (customDomain != null && customDomain.isNotEmpty) {
    _prefs.initPreferences(customDomain: customDomain);

    _channelNative.setMethodCallHandler(
        (call) => _NativeFunctionsContainer.backendlessEventHandler(call));
    return;
  } else if (applicationId?.isNotEmpty ?? true) {
    String? apiKey;

    if (kIsWeb) {
      throw PlatformException(
          code: '0',
          message: 'In alpha version web unsupported for this skd.');
      //apiKey = jsApiKey;
    } else if (io.Platform.isAndroid) {
      apiKey = androidApiKey;
    } else {
      _channelNative.setMethodCallHandler(
          (call) => _NativeFunctionsContainer.backendlessEventHandler(call));
      apiKey = iosApiKey;
    }

    if (apiKey == null) {
      throw ArgumentError.value(ExceptionMessage.emptyNullApiKey);
    }

    await _prefs.initPreferences(appId: applicationId, apiKey: apiKey);
    _isInitialized = true;
    return;
  }

  throw ArgumentError.value(ExceptionMessage.emptyNullAppId);
}