Connect to Ignite

When connecting to Ignite, ensure the Host App is in the foreground, active, and visible to the user. DT sends callbacks on the thread that the initialization was executed on.

There are no restrictions on the lifecycle owners for the connection: Activity, Fragment, Service, ViewModel, etc. However, do not connect to Ignite from classes or methods that might be called while the Host App is in the background, such as the Application class or broadcast receivers. Connecting in this manner causes multiple unnecessary connection attempts, potential resource conflicts, and unexpected behaviors when receiving broadcasts in the background.

After successful initialization and authentication, the SDK persists an authorization token and refreshes it as needed. The SDK uses the token for any requests that require authorization.

circle-info

Initialization failure indicates that Ignite is not present on the device.

To connect to Ignite via the SDK:

  1. Declare and create an instance of IIgniteService:

Kotlin
lateinit var igniteService: IIgniteService
// ...

// After SDK is initialised the IgniteService instance is returned.
// It can also be retrieved later using IgniteServiceSdk.instance()
// NOTE: `clientSecret` can be empty for initial integration
igniteService = IgniteServiceSdk.init(context, clientSecret)
  1. Call the connect() method:

Kotlin
IgniteServiceSdk.instance().connect(object: IConnectionCallback {
     override fun onConnected() {
          // Connection with Ignite is established
          Toast.makeText(applicationContext, "Connected.", Toast.LENGTH_SHORT).show()
     }

	 override fun onAuthenticated() {
	      // Client is now able to call API methods
          Toast.makeText(applicationContext, "Authenticated.", Toast.LENGTH_SHORT).show()
     }

     override fun onDisconnected(message: String?) {
          Toast.makeText(applicationContext, "Disconnected from Ignite Service: $message", Toast.LENGTH_SHORT).show()
     }
})

// or

igniteService.connect(this)

Example

Troubleshooting Connections

If your Host App is unable to connect to Ignite, you may receive one of the following error messages:

ERROR MESSAGE
DESCRIPTION

Connection failed to unknown reason

Ignite is not present in the device.

Authentication Exception: Can not create session

Client ID, Client Secret, or package name does not match what was given for DT Configuration.

Authentication Exception Code -2

Host App signing certificate fingerprint does not match with what was provided for DT Configuration.

Last updated