Skip to content

Initialization

IWidgetsApi

The IWidgetsApi interface represents the entry point to the widget feature. It exposes the needed API to initiate the widget functionality. All clients should use the implementation of this interface for starting the widget feature.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
interface IWidgetsApi {

    fun init(
        actions: List<String> = emptyList(),
        context: Context,
        sdkOptions: SDKOptions
    )

    fun clear(context: Context)
}


The init method initializes the widget functionality and registers the broadcast receiver with the required actions.

The actions parameter represents the actions that are registered for extra communication with the client that integrates the widgets.

The context parameter represents the context used for registering the broadcast receiver.

The sdkOptions parameter represents the component used by the client to set the apiKey, apiSecret, endpoint, applicationID.

The Client app needs to include the telenav-sdk-base library and set the mandatory options in order to use the commerce widgets.

1
2
3
4
5
fun init(
        actions: List<String> = emptyList(),
        context: Context,
        sdkOptions: SDKOptions
    )


The clear method unregisters all receivers.

The context parameter represents the context used for unregistering all broadcast receivers.

1
fun clear(context: Context)

Access the IWidgetsApi

In order to access the IWidgetsApi, use the following code.

1
WidgetsManagerProvider.provide()

Initialize the IWidgetsApi

In order to initialize the IWidgetsApi, use the following code.

1
2
3
4
5
6
WidgetsManagerProvider.provide()
    .init(
        actionsList,
        this,
        getSDKOptions()
    )

SDKOptions

In order to build SDKOptions, use the following code.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
fun getSDKOptions(): SDKOptions {
    val sdkOptions = SDKOptions.builder()
    sdkOptions.setApiKey(BuildConfig.API_KEY)
    sdkOptions.setApiSecret(BuildConfig.API_SECRET)
    sdkOptions.setCloudEndPoint(STAGE_ENDPOINT_VALUE)
    val applicationInfo =
        ApplicationInfo.builder(
            "app_id",
            "app_version"
        )
    sdkOptions.setApplicationInfo(applicationInfo.build())
    return sdkOptions.build()
}

Info

All the widgets interaction is handled from inside.