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.
Kettle.shared.grant(consents: [.surveys, .analytics, .campaigns, .ads])
Revoking consents
Removes previously granted user consent.
Kettle.shared.revoke(consents: [.surveys, .analytics, .campaigns, .ads])
Retrieve granted consents
Returns an array containing the consents granted to Kettle.
let consents: [KettleConsent] = Kettle.shared.grantedConsents
Start Kettle
Starts collecting data for given modules.
Kettle.shared.start(with: [.bluetooth, .location, .activity])
Stop Kettle
Stops collecting data from given modules.
Kettle.shared.stop(with: [.bluetooth, .location, .activity])
Retrieve SDK status
Returns true if Kettle is currently enabled and collecting data.
let kettleStarted: Bool = Kettle.shared.started
Assign external identifier
Forwards the users internal user ID to Kettle, allowing Kogenta to map your internal identifier with the users Kettle ID.
Kettle.shared.externalId = "<EXTERNAL-IDENTIFIER>"
Kettle Identifier
Returns the internal Kettle ID for the user.
let kettleId: String = Kettle.shared.identifier
Send custom data
This functions performs a POST request. It accepts a string dictionary of AnyHashable.
let type = "order"
var event: [String : AnyHashable] = [:]
event["orderId"] = 12
Kettle.shared.addCustomEvent(type: type, event: event)
Send metadata
This functions performs a PUT request. It accepts a string dictionary of AnyHashable.
let type = "name"
var metadata: [String : AnyHashable] = [:]
metadata["nick_name"] = "nick"
Kettle.shared.setMetadata(type: type, metadata: metadata)
Privacy terms URL
let privacyTermsUrl: String = Kettle.shared.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.
let 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.
let authenticatedSiteUrl: String = Kettle.shared.getAuthenticatedUrl(urlString: "https://kogenta.com")
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.
Kettle.shared.deleteCollectedData() { didRequestDeletion in
if didRequestDeletion {
...
}
}
Requesting bluetooth permission
Convenience method to trigget bluetooth permission dialog.
Kettle.shared.requestBluetoothPermission()
Assign push token
Forwards the users push token to Kettle, allowing it to send push notifications.
Kettle.shared.pushToken = "<PUSH-TOKEN>"
Handle push notification events
To enable Kettle to track push notification interactions, you need to forward specific notification events to the SDK.
Receiving remote notifications
When your app receives a remote notification (both in foreground and background), pass the notification data to Kettle:
func application(_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable : Any],
fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
Kettle.shared.didReceiveRemoteNotification(userInfo: userInfo)
...
}
For foreground notifications using UNUserNotificationCenterDelegate:
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
let userInfo = notification.request.content.userInfo
Kettle.shared.didReceiveRemoteNotification(userInfo: userInfo)
...
}
User opened notification
When a user taps on a notification to open the app, inform Kettle about this interaction:
func userNotificationCenter(_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
let userInfo = response.notification.request.content.userInfo
Kettle.shared.didOpenNotification(userInfo: userInfo)
...
}
Deep links and URL handling
If your app is opened via a custom URL scheme or universal link, notify Kettle in case any project-specific deep link logic needs to be handled by the SDK.
// In your SwiftUI App
var body: some Scene {
WindowGroup {
ContentView()
.onOpenURL { url in
Kettle.shared.didOpenApplicationWithUrl(url: url.absoluteString)
}
}
}
For UIKit-based apps using UIApplicationDelegate:
func application(_ app: UIApplication,
open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
Kettle.shared.didOpenApplicationWithUrl(url: url.absoluteString)
return true
}