> ## Documentation Index
> Fetch the complete documentation index at: https://docs.clix.so/llms.txt
> Use this file to discover all available pages before exploring further.

# User Management

> User management in the Clix SDK allows you to distinguish between anonymous users and identified users within your app. This ensures that push notifications, in-app messaging, and analytics can be personalized and consistent across devices and sessions.

You can check how to use the API in the Clix SDK GitHub repositories for each platform:

* [iOS](https://github.com/clix-so/clix-ios-sdk#user-management)
* [Android](https://github.com/clix-so/clix-android-sdk#user-management)
* [React Native](https://github.com/clix-so/clix-react-native-sdk#user-management)
* [Flutter](https://github.com/clix-so/clix-flutter-sdk#user-management)

For additional conceptual details, see the [Clix Documentation on User](https://docs.clix.so/essentials/user).

<Info>
  If no user ID is set, Clix will automatically treat the user as **anonymous**
  with only a device ID and an auto-generated `project-user-id`.
</Info>

<Info>
  If a user ID is set, the anonymous user will be **converted** into an
  **Identified User**, linking all their previous activity with their account.
</Info>

## When to Use User Management

<Steps>
  <Step title="Anonymous user (default)">
    By default, when your app starts without setting a user ID, Clix assigns an
    **anonymous profile**. This is useful when users are browsing your app
    without logging in.
  </Step>

  <Step title="Identified user (after login/signup)">
    Once a user logs in or creates an account, you can call the **User
    Management API** to assign a permanent `userId`. This converts the anonymous
    user to an **Identified User**, ensuring continuity of notifications,
    preferences, and analytics across devices.
  </Step>

  <Step title="User logout">
    When a user logs out, you don't need to take any action. Events after
    logout are attributed to the last known user. Call `reset()` only if you
    need to fully anonymize the user (e.g., shared devices).
  </Step>
</Steps>

***

## User Logout / Reset

By default, you don't need to handle logout explicitly. Events sent after logout are attributed to the last known user, which is sufficient for most use cases.

If you need to explicitly log users out or track events under an anonymous user (e.g., shared devices where multiple people sign in), call `reset()`. This anonymizes the user by:

* Setting the user ID to null
* Clearing the device ID so a new one is generated on next initialization

With an empty user ID and a completely new device ID, the current user appears as a brand new anonymous user in the dashboard. After calling `reset()`, you must call `initialize()` again before using the SDK.

<CodeGroup>
  ```swift iOS theme={null}
  // On logout
  Clix.reset()

  // On next login
  Clix.initialize(config: config)
  Clix.setUserId("user_12345")
  ```

  ```kotlin Android theme={null}
  // On logout
  Clix.reset()

  // On next login
  Clix.initialize(context, config)
  Clix.setUserId("user_12345")
  ```

  ```typescript React Native theme={null}
  // On logout
  await Clix.reset();

  // On next login
  await Clix.initialize({ projectId: "...", apiKey: "..." });
  await Clix.setUserId("user_12345");
  ```

  ```dart Flutter theme={null}
  // On logout
  await Clix.reset();

  // On next login
  await Clix.initialize(ClixConfig(projectId: "...", apiKey: "..."));
  await Clix.setUserId("user_12345");
  ```
</CodeGroup>

<Warning>
  `removeUserId()` is deprecated. Use `reset()` instead.
</Warning>

***

## Example Usage

```swift theme={null}
// 1. Anonymous user (default)
// No userId is set, Clix generates a project-user-id internally

// 2. Identified user
// After login, set a unique userId
Clix.setUserId("clix_user")
```

## Setting User Properties

You can attach custom properties to a user profile for personalization and analytics. Properties can be strings, numbers, or booleans.

**Set a single property (async):**

```swift theme={null}
try await Clix.setUserProperty("subscription", value: "premium")
```

**Set multiple properties (async):**

```swift theme={null}
try await Clix.setUserProperties([
  "age": 25,
  "city": "Seoul",
  "premium": true
])
```

**Set a single property (sync):**

```swift theme={null}
Clix.setUserProperty("subscription", value: "premium")
```

**Set multiple properties (sync):**

```swift theme={null}
Clix.setUserProperties([
  "age": 25,
  "city": "Seoul",
  "premium": true
])
```

***

## Removing User Properties

You can remove one or more properties from a user profile.

**Remove a single property (async):**

```swift theme={null}
try await Clix.removeUserProperty("subscription")
```

**Remove multiple properties (async):**

```swift theme={null}
try await Clix.removeUserProperties(["age", "premium"])
```

**Remove a single property (sync):**

```swift theme={null}
Clix.removeUserProperty("subscription")
```

**Remove multiple properties (sync):**

```swift theme={null}
Clix.removeUserProperties(["age", "premium"])
```

***

## Error Handling

All user management operations can throw errors. Always handle errors for robust apps:

**Error handling example:**

```swift theme={null}
do {
  try await Clix.setUserId("user123")
} catch {
  print("Failed to set user ID: \(error)")
}
```
