initialize method

  1. @override
Future<bool> initialize({
  1. String? applicationSecret,
  2. String? apiKey,
  3. String? apiSecret,
  4. String? domain,
  5. String? userId,
  6. bool? developmentApns,
})
override

Initialize Dimelo/Engage Digital Messaging SDK on the native side.

This method must be called before using any other functionality.

Parameters:

  • apiKey - Your Dimelo API key (required)
  • domain - The service domain/endpoint (required)
  • userId - Optional external user ID to bind the session
  • applicationSecret - Optional application secret
  • apiSecret - Optional API secret
  • developmentApns - Whether to use development APNS (iOS only)

Returns true if initialization was successful, false otherwise.

Implementation

@override
Future<bool> initialize({
  String? applicationSecret,
  String? apiKey,
  String? apiSecret,
  String? domain,
  String? userId,
  bool? developmentApns,
}) async {
  try {
    // Prepare parameters for native SDK initialization
    final result = await methodChannel.invokeMethod<bool>('initialize', <String, dynamic>{
      'applicationSecret': applicationSecret,
      'apiKey': apiKey,
      'apiSecret': apiSecret,
      'domain': domain,
      'userId': userId,
      'developmentApns': developmentApns,
    });
    // Return result or false if null
    return result ?? false;
  } on PlatformException catch (e) {
    // Log error and return false on platform exception
    debugPrint('Failed to initialize Dimelo: ${e.message}');
    return false;
  }
}