Functions
INIT
This method MUST be called before any other interactions with the SDK; otherwise, unexpected behaviors may occur. Usually, you should call this method from your custom [android.app.Application].
Told.init(
configuration = ToldConfiguration(
sourceId = "MySourceId",
applicationId = applicationContext.packageName,
environment = ToldEnvironment.Production,
),
applicationContext = applicationContext,
)
IDENTIFY
This function updates the current user information. Use it when you need to provide information, log in, or update details.
Told.identify(properties: Map<String, Any>)
SET LANGUAGE
In the editor, you can configure multiple languages. By default, the sdk will detect the user's language. If the language differs from the one set up in your application, it will revert to the default language. To customize these settings, simply include the key "language" along with its corresponding value in the identify.
Told.identify(mapOf("language" to "en"))
TRACK EVENT
Track any custom event you declare on Told.
Told.trackEvent(eventName: String,properties: Map<String, Any> = emptyMap())
REGISTER NAV CONTROLLER
Registers a navigation controller to listen for destination changes and perform logging and tracking actions.
This function adds an OnDestinationChangedListener
to the provided navController
. Each time the navigation
destination changes, an event is send to Told.
The destinationName
is the full qualified name of your destination. If you have a destination called MyDestination
,
the name send will be my.package.MyDestination. This name must match the name you enter on Told website.
val navController: NavHostController = rememberNavController()
LaunchedEffect(key1 = navController) {
Told.registerNavController(navController = navController)
}
REGISTER ACTIVITY CALLBACK
Allows listening to activity changes throughout the application and launching a survey if needed. This method should be called only once during your application’s lifecycle.
If your application’s navigation is entirely based on one or more NavController, you should use only registerNavController
.
If your navigation is activity-based, you can use registerActivityCallback
.
Told.registerActivityCallback()
UNREGISTER ACTIVITY CALLBACK
If you need to unregister your callback manually, you can call this method.
If you use registerActivityCallback
in your android.app.Application
or if you only use registerNavController
, this method
should be useless for you.
Told.unregisterActivityCallback()
START
Start a survey with the provided surveyId.
Told.start(surveyId: String, withDelay: Duration = 0.seconds)
RESET
Upon logout, the user's data should be reset to make them an anonymous person again.
Told.reset(newConfiguration: ToldConfiguration? = null)
DEBUG WIDGET
Get information about your source and your surveys. It will be displayed in your Logcat as a debug log.
Told.debugWidget()