Skip to main content
SDK Version

Standard

In this guide, we will take a closer look at how to properly handle device registration within Actito.

When you invoke launch() for the first time, the SDK registers the device as a non-push device. This initial registration enables Actito to begin tracking user engagement, categorizing users through tags, and enriching user profiles with known data.

Device registration is a fundamental component of how Actito operates and underpins many of its core features.

You can view the current device information at any time using:

Actito.shared.device().currentDevice

Once launch() completes, the SDK is fully initialized and ready for interaction.

Assigning a user to the device

By default, a newly registered device is associated with an anonymous user. However, in applications where users authenticate, you should explicitly associate the device with the authenticated user’s information.

This can be achieved as follows:

do {
try await Actito.shared.device().updateUser(
userId: "7f42bedc-d74b-4c64-a5cf-76bcc5130b05",
userName: "John Doe"
)
} catch {
// Handle error
}

After this call, the device remains linked to the provided userId and userName until they are explicitly cleared. Depending on your authentication flow, you may wish to verify the user’s login state after launching and update the registration accordingly.

To reset the device to an anonymous user, set both parameters to nil:

do {
try await Actito.shared.device().updateUser(userId: nil, userName: nil)
} catch {
// Handle error
}

Overriding the device language

By default, Actito automatically detects the device’s language and region based on the system Locale. In most scenarios, this behavior is sufficient. However, if you need to enforce a specific language and region combination — for instance, when your app supports a limited set of locales — you can override the default by invoking:

do {
try await Actito.shared.device().updatePreferredLanguage("en-US")
} catch {
// Handle error
}

You can retrieve the currently configured preferred language at any time with:

Actito.shared.device().preferredLanguage