onInitializeError

❌ Event: onInitializeError

📘 Description

This event is emitted when the SDK fails to initialize. It provides an error object describing what went wrong — typically due to network issues, invalid configuration, or unsupported environments.

This event is critical for debugging and should be handled gracefully to guide the user (e.g., showing a retry option or error message).


📱 Platform Support

PlatformSyntax
React NativerdnaEventRegistery.addListener('onInitializeError', this.handler)
FlutterrdnaClient.on(RdnaClient.onInitializeError, onInitializeError);
Cordovadocument.addEventListener('onInitializeError', this.handler, false);
Native iOS(void)onInitializeError:(RDNAError *)error;
Native Androidvoid onInitializeError(RDNAError error);

📤 Response Format

The event provides an error object of type RDNAError, containing the following fields:

{
  "longErrorCode": 539001401,
  "shortErrorCode": 12,
  "errorString": "Failed to connect to server. Kindly check your internet connection."
}

🔍 Error Object Fields

FieldTypeDescription
longErrorCodeNumberUnique long code identifying the specific error.
shortErrorCodeNumberGeneric short error code for simplified error categorization.
errorStringStringHuman-readable explanation of the error.

🧠 Developer Notes

  • Always handle this event to capture initialization failures and provide a retry or fallback mechanism.
  • Use the shortErrorCode to map errors to common actions (e.g., network retry, config fix).
  • Check for network reachability or invalid configuration before retrying initialize().

🧪 Sample Errors

shortErrorCodeMeaningSuggested Action
12Network connection failedAsk user to check internet connectivity
11Invalid agent in connection profileContact REL-ID admin for config validation
88SDK already initializedCall terminate() before reinitializing


🔌 Event Handling

onInitializeError Event

React Native
// Import the necessary modules
import RdnaClient from 'react-native-rdna-client';

// This is an event handler, not a method to call directly
// Set up event listener for onInitializeError event
let onInitializeErrorSubscription = rdnaEventRegistery.addListener(
  'onInitializeError', (response) => {
    // Handle the response
    console.log("onInitializeError event received:", response);
    // Implement your logic here
  }
);

// Don't forget to remove the event listener when component unmounts
componentWillUnmount() {
  onInitializeErrorSubscription.remove();
}
Flutter
import 'package:flutter/material.dart';
import 'package:rdna_plugin/rdna_plugin.dart';

// This is an event handler, not a method to call directly
// Set up event listener for onInitializeError event
rdnaClient.on(RdnaClient.onInitializeError, onInitializeError);

// Define the callback function
void onInitializeError(RDNAInitializeError response) {
  // Handle the response
  print("onInitializeError event received");
  // Implement your logic here
}
Cordova
// This is an event handler, not a method to call directly
// Set up event listener for onInitializeError event
document.addEventListener('onInitializeError', onInitializeError);

// Define the callback function
function onInitializeError(response) {
  // Handle the response
  console.log("onInitializeError event received:", response);
  // Implement your logic here
}
Native iOS
// Objective-C
// This is an event handler, not a method to call directly
// Implement the event handler method
- (void)onInitializeError:(RDNAChallengeResponse *)response {
    // Handle the response
    NSLog(@"onInitializeError event received");
    // Implement your logic here
}

// Swift
// This is an event handler, not a method to call directly
// Implement the event handler method
func onInitializeError(_ response: RDNAChallengeResponse) {
    // Handle the response
    print("onInitializeError event received")
    // Implement your logic here
}
Native Android
// This is an event handler, not a method to call directly
// Implement the event handler method
@Override
public void onInitializeError(RDNA.RDNAChallengeResponse response, RDNAError error) {
    // Handle the response
    Log.d("REL-ID", "onInitializeError event received");
    // Implement your logic here
}


_