Usage
Kettle
Consents
KettleConsent.SURVEYS
KettleConsent.ANALYTICS
KettleConsent.CAMPAIGNS
KettleConsent.ADS
Granting consents
Defines what the data collected from the user can be used for. At least one consent is required to collect data with Kettle.
Kettle.grant(arrayOf(KettleConsent.ANALYTICS, KettleConsent.SURVEYS, KettleConsent.CAMPAIGNS, KettleConsent.ADS))
Revoking consents
Removes previously granted user consent.
Kettle.revoke(arrayOf(KettleConsent.ANALYTICS, KettleConsent.SURVEYS, KettleConsent.CAMPAIGNS, KettleConsent.ADS)) {
success ->
if (success) // ...
}
Retrieve granted consents
Returns an array containing the consents granted to Kettle.
val grantedConsents = Kettle.grantedConsents
Start Kettle
The SDK will remember that it has been started. Subsequent calls are uneccessary, unless app cache is cleared.
Starts collecting data for given modules.
Kettle.start(arrayOf(KettleModule.BLUETOOTH, KettleModule.LOCATION, KettleModule.ACTIVITY))
Stop Kettle
Stops collecting data from given modules.
Kettle.stop(arrayOf(KettleModule.BLUETOOTH, KettleModule.LOCATION, KettleModule.ACTIVITY))
Retrieve SDK status
Returns true if Kettle is currently enabled and collecting data.
val kettleStarted: Boolean = Kettle.started
Assign push token
Forwards the users push token to Kettle, allowing it to send push notifications.
Kettle.pushToken = "<PUSH-TOKEN>"
Assign external identifier
Forwards the users internal user ID to Kettle, allowing Kogenta to map your internal identifier with the users Kettle ID.
Kettle.externalId = "<EXTERNAL-IDENTIFIER>"
Kettle Identifier
Returns the internal Kettle ID for the user.
val kettleId: String = Kettle.identifier
Privacy terms URL
val privacyTermsUrl: String = Kettle.privacyTermsUrl
Privacy dashboard URL
The URL for the Kogenta Privacy Dashboard. This site can be used to view all data collected by Kettle, exporting data and request deletion of data.
val privacyDashboardUrl: String = Kettle.shared.privacyDashboardUrl
Authenticated URL
Generates an authenticated URL by appending an authorization token to given URL. A 404 site is returned if the given URL is invalid.
val authenticatedSiteUrl: String = Kettle.getAuthenticatedUrl(url = "https://kogenta.com")
Send demographic profile
You can send user demographic profile to the Kettle by calling:
Kettle.sendDemographicProfile(
DemographicProfile(
birthYear = xxxx,
gender = DemographicProfile.Gender.UNKNOWN
)
)
Send custom data
This function only accepts stringified json. If anything else is supplied, it will be thrown away quietly.
val type = "order"
val json = "{\"orderId\": \"12\", \"items\": [1, 2, 3]}"
Kettle.addCustomEvent(type, json)
Send metadata
This function only accepts stringified json. If anything else is supplied, it will be thrown away quietly.
This method performs a PUT request, replacing any previous values sent with the same type.
val type = "name"
val json = "{\"nickname\": \"jas\"}"
Kettle.setMetadata(type, json)
Delete collected PII & Data
Calling this method will request deletion of all data collected by Kettle for the user. This method will delete all data currently residing on the device, as well as request deletion of data in cloud. It requires an active internet connection and accepts an optional closure that can be used to verify that the deletion request was successfully sent. If internet access was not available at the time, the request will be retried when one is available.
Kettle.deleteCollectedData { didDelete ->
print("data deleted: $didDelete")
}
Requesting bluetooth permission
Convenience method to trigget bluetooth permission dialog.
Kettle.shared.requestBluetoothPermission()
Kettle Messaging Center
Retrieve messages
All fields in KettleMessage
except created
, expiry
and opened
can be null.
KettleMessagingCenter.getMessages { messages ->
messages.forEach { msg ->
// do something with the messages
}
}