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

# Manage Users

> Methods to create user and set their mobile push token and other communication channels for sending notifications in ReactNative application.

## How Suprsend identifies a user

SuprSend identifies users with immutable `distinct_id`. It's best to map the same identifier in your DB with `distinct_id` in SuprSend. Do not use identifiers that can be changed like email or phone number. You can view synced users by searching `distinct_id` on [Users page](https://app.suprsend.com/en/production/users).

## Identify user and Set Push token

<Steps>
  <Step title="Create/Identify a new user">
    You can identify a user using the`suprsend.identify()` method. iospsuh token is automatically set in user's profile when this method is called.
    Call this method as soon as you know the identity of user, that is after login authentication. If you don't call this method, user will be identified using distinct\_id (uuid) that SDK generates internally.

    We internally create an event called **`$user_login`**. You can see this event on SuprSend workflows event list and you can configure a workflow on it.

    <CodeGroup>
      ```javascript javascript theme={"system"}
      suprsend.identify(distinct_id);

      //Sample Values
      suprsend.identify("291eaa13-62f5-4d52-b2dd");
      ```
    </CodeGroup>

    | Parameters       | Type                      | Description                                                                         |
    | ---------------- | ------------------------- | ----------------------------------------------------------------------------------- |
    | **distinct\_id** | int, bigint, string, UUID | *mandatory* Unique identifier for a user across devices or between multiple logins. |
  </Step>

  <Step title="Call reset to clear user data on log out">
    As soon as the user logs out, call `suprsend.reset()` method to clear data attributed to a user. This allows you to handle multiple user logins on a single device and keep their data isolated from each other.

    <CodeGroup>
      ```javascript javascript theme={"system"}
      suprsend.reset();
      ```
    </CodeGroup>

    <Warning>
      Don't forget to call reset on user logout. If not called, users' distinct\_id will not reset and multiple tokens and channels will get added to the distinct\_id who logged in first on the device.
    </Warning>
  </Step>
</Steps>

## Set communication channels

Mobile Push tokens automatically gets updated in user profile on `suprsend.identify()` call. All you have to do is to integrate [push notification ](/docs/flutter-androidpush-integration)service in your application to start sending mobile push notification. To set other communication channels, use below methods:

<Accordion title="Add User Channels" defaultOpen={false}>
  Add user channels on signup, or whenever a user updates their communication channels in the application flow.

  ```javascript Javascript theme={"system"}
  suprsend.user.setEmail("user@example.com");  // To add Email

  suprsend.user.setSms("+91XXXXXXXXXX");  // To add SMS, mandatory to pass country code

  suprsend.user.setWhatsApp("+91XXXXXXXXXX"); // To add Whatsapp, mandatory to pass country code
  ```
</Accordion>

<Accordion title="Remove User Channels" defaultOpen={false}>
  ```
  suprsend.user.unSetEmail("user@example.com");  // To remove Email

  suprsend.user.unSetSms("+91XXXXXXXXXX");  // To remove SMS

  suprsend.user.unSetWhatsApp("+91XXXXXXXXXX"); // To remove Whatsapp
  ```
</Accordion>

## Set user properties

(*currently not available in iOS SDK*)

You can sync other user properties in SuprSend and use it to pass dynamic content in template or add in workflow conditions.

<AccordionGroup>
  <Accordion title="Set" defaultOpen={false}>
    Set is used to add property. Set is upsert function and will override existing values corresponding to a key.

    <CodeGroup>
      ```javascript javascript theme={"system"}
      // for single property
      suprsend.user.set(key, value);
      suprsend.user.set("name", "john doe");

      // for multiple properties
      suprsend.user.set(property_obj);
      suprsend.user.set({"name" :  "john doe", "age" : "27"});
      ```
    </CodeGroup>

    <Warning>
      Key should not start with **`$`** or **`ss_`**, as we have reserved these symbols for our internal events and property names.
    </Warning>
  </Accordion>

  <Accordion title="Set Once" defaultOpen={false}>
    Works just like `user.set`, except it will not overwrite existing property values. This is useful for properties like *First login date*

    <CodeGroup>
      ```javascript javascript theme={"system"}
      suprsend.user.setOnce(key, value);  // for single property
      suprsend.user.setOnce(properties);  // for multiple properties

      // Sample values for setting once a single property:
      suprsend.user.setOnce("first_login", "2021-11-02");

      // Sample values for setting once multiple properties:
      suprsend.user.setOnce({"first_login" : "2021-11-02", "DOB" : "1991-10-02"});
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Unset" defaultOpen={false}>
    This will remove a property key

    <CodeGroup>
      ```javascript javascript theme={"system"}
      suprsend.user.unSet(key);  // for single property
      suprsend.user.unSet(property_list);  // for multiple properties

      // Sample values for unsetting a single property:
      suprsend.user.unSet("wishlist");

      // Sample values for unsetting multiple properties:
      suprsend.user.unSet(["wishlist", "cart"]);
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Append" defaultOpen={false}>
    This method will append a value to an array

    <CodeGroup>
      ```javascript javascript theme={"system"}
      suprsend.user.append(key, value);
      suprsend.user.append(property_obj);  // for multiple properties

      // Sample values for appending a single property:
      suprsend.user.append("wishlist", "iphone12");

      // Sample values for appending multiple properties:
      suprsend.user.append({"wishlist" : "iphone12", "wishlist" : "Apple airpods"});
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Remove" defaultOpen={false}>
    This will remove value from an array but not remove property key

    <CodeGroup>
      ```javascript javascript theme={"system"}
      // for single property
      suprsend.user.remove(key, value);
      suprsend.user.remove("wishlist", "iphone12");

      // for multiple properties
      suprsend.user.remove(property_obj);
      suprsend.user.remove({"wishlist" : "iphone12", "wishlist": "Apple airpods"});
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Increment" defaultOpen={false}>
    Increase or decrease integer values on consecutive action, like login count. To reduce a property, provide a negative number for the value.

    <CodeGroup>
      ```javascript javascript theme={"system"}
      // for single property
      suprsend.user.increment(key, value);
      suprsend.user.increment("login_count", 1);

      // for multiple properties
      suprsend.user.increment(property_obj);
      suprsend.user.increment({"login_count" : 1, "order_count" : 1});
      // Sample values for incrementing a single property:


      // Sample values for incrementing multiple properties:

      ```
    </CodeGroup>
  </Accordion>
</AccordionGroup>

***
