Complete API reference for device mode integration APIs in the Android (Kotlin) and iOS (Swift) SDKs.
4 minute read
This reference provides the complete API specifications for device mode integration APIs in the RudderStack Android (Kotlin) and iOS (Swift) SDKs.
onDestinationReady()
onDestinationReady() registers a callback to be invoked when the destination for an integration plugin is ready. Use this method to perform actions only after the destination has been successfully configured and initialized. For example, fetching an ID from the destination instance or initializing resources.
Behavior
If the destination is ready, the callback is invoked immediately with the destination instance and a success result.
If the destination is not ready, the callback is stored and invoked once initialization completes (or fails).
Android (Kotlin)
This section covers the onDestinationReady() method signature, parameters, and return type applicable for the Android (Kotlin) SDK.
instance: The destination instance (Any?) - nil if initialization failed
result: A Result<Any, Error> indicating success or failure
Return type
Void
Example
integrationPlugin.onDestinationReady{instance,resultinswitchresult{case.success:// Destination is ready, safe to send eventsprint("Destination is ready: \(String(describing:instance))")case.failure(leterror):// Handle initialization failureprint("Destination initialization failed: \(error.localizedDescription)")}}
[self.analyticsonDestinationReadyForKey:integration.key:^(id_Nullabledestination,NSError*_Nullableerror){if(error==nil){// Destination is ready, safe to send events
[RSSLoggerAnalyticsdebug:[NSStringstringWithFormat:@"Destination is ready: %@",destination]];}else{// Handle initialization failure
[RSSLoggerAnalyticsdebug:[NSStringstringWithFormat:@"Destination initialization failed: %@",[errorlocalizedDescription]]];}}];
getDestinationInstance()
getDestinationInstance() returns the destination instance that was created and initialized by the integration plugin. This allows direct access to the destination object for advanced use cases like interacting with the destination SDK, accessing APIs, or implementing install attribution.
Behavior
Returns the destination instance if available
Returns null or nil if not yet initialized
Android (Kotlin)
This section covers the getDestinationInstance() method signature, parameters, and return type applicable for the Android (Kotlin) SDK.
Method signature
fungetDestinationInstance():Any?
Parameters
None
Return type
Any?: The destination instance, or null if not initialized
Example
valdestination=integrationPlugin.getDestinationInstance()if(destination!=null){// Interact with the destination SDK
println("Destination instance: $destination")// Cast to specific destination type if needed
// val firebaseDestination = destination as? FirebaseAnalytics
}
Objectdestination=integrationPlugin.getDestinationInstance();if(destination!=null){// Interact with the destination SDK
System.out.println("Destination instance: "+destination);// Cast to specific destination type if needed
// FirebaseAnalytics firebaseDestination = (FirebaseAnalytics) destination;
}
iOS (Swift)
This section covers the getDestinationInstance() method signature, parameters, and return type applicable for the iOS (Swift) SDK.
Method signature
funcgetDestinationInstance()->Any?
Parameters
None
Return type
Any?: The destination instance, or nil if not initialized
Example
ifletdestination=integrationPlugin.getDestinationInstance(){// Interact with the destination SDKprint("Destination instance: \(destination)")// Cast to specific destination type if needed// let firebaseDestination = destination as? Analytics}
iddestination=[integrationgetDestinationInstance];if(destination!=nil){// Interact with the destination SDK
[RSSLoggerAnalyticsdebug:[NSStringstringWithFormat:@"Destination instance: %@",destination]];// Cast to specific destination type if needed
// Analytics *firebaseDestination = [integration getDestinationInstance];
}
When to use each API
Use onDestinationReady() when:
You need to perform critical startup logic that requires the destination to be ready
You want guaranteed access to a non-null instance via an asynchronous callback
You need to handle initialization failures explicitly
Use getDestinationInstance() when:
You need on-demand access later in the app lifecycle
You want to avoid callback overhead
You can handle a null or nil return value if the instance isn’t ready yet
Error conditions
This section covers the error conditions for the onDestinationReady() and getDestinationInstance() APIs.
onDestinationReady()
The callback receives a failure result in the following cases:
The destination SDK initialization throws an exception
The destination plugin fails to create the destination instance
The destination configuration is invalid or missing required parameters
You can access the error details through the Result.Failure object (Android) or Error parameter (iOS) in the callback.
getDestinationInstance()
Returns null (Android) or nil (iOS) when:
The destination has not been initialized yet
The destination initialization failed
The integration plugin was not added to the Analytics instance
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.