onInitializeError
❌ Event: onInitializeError
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
| Platform | Syntax |
|---|---|
| React Native | rdnaEventRegistery.addListener('onInitializeError', this.handler) |
| Flutter | rdnaClient.on(RdnaClient.onInitializeError, onInitializeError); |
| Cordova | document.addEventListener('onInitializeError', this.handler, false); |
| Native iOS | (void)onInitializeError:(RDNAError *)error; |
| Native Android | void 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."
}🔍 Field Definitions
| Field | Type | Description |
|---|---|---|
longErrorCode | Number | Unique long code identifying the specific error. |
shortErrorCode | Number | Generic short error code for simplified error categorisation. |
errorString | String | Human-readable explanation of the error. |
🧠 Developer Notes
- Always handle this event to capture initialization failures and provide a retry or fallback mechanism.
- Use the
shortErrorCodeto map errors to common actions (e.g., network retry, config fix). - Check for network reachability or invalid configuration before retrying
initialize().
🧪 Sample Errors
| shortErrorCode | Meaning | Suggested Action |
|---|---|---|
| 12 | Network connection failed | Ask user to check internet connectivity |
| 11 | Invalid agent in connection profile | Contact REL-ID admin for config validation |
| 88 | SDK already initialized | Call terminate() before reinitializing |
✅ Recommended UI Usage
🟡 Display the appropriate error message with shot error code and long error code value on dialog or new screen.
🟡 Provide the appropriate action buttons for the retry or terminatre hte app.📱 Platform-specific Integration
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
}_
Updated about 1 month ago
