Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 55 additions & 4 deletions content/shared/user-management/setting-user-properties.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,31 @@ description: "Customize paywalls and target users by setting user attributes"

By setting user attributes, you can display information about the user on the paywall. You can also define [audiences](/dashboard/dashboard-campaigns/campaigns-audience) in a campaign to determine which paywall to show to a user, based on their user attributes.

:::ios
<Note>
If a paywall uses the **Set user attributes** action, the merged attributes are sent back to your app via `SuperwallDelegate.userAttributesDidChange(newAttributes:)`.
</Note>
:::

You do this by passing a `[String: Any?]` dictionary of attributes to `Superwall.shared.setUserAttributes(_:)`:
:::android
<Note>
If a paywall uses the **Set user attributes** action, the merged attributes are sent back to your app via `SuperwallDelegate.userAttributesDidChange(newAttributes:)`.
</Note>
:::

:::flutter
<Note>
If a paywall uses the **Set user attributes** action, the merged attributes are sent back to your app via `SuperwallDelegate.userAttributesDidChange(newAttributes:)`.
</Note>
:::

:::expo
<Note>
If a paywall uses the **Set user attributes** action, the merged attributes are sent back to your app via the `onUserAttributesChange` callback in `useSuperwallEvents`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Document a real Expo attribute-change hook

For Expo users trying to react to a paywall Set user attributes action, this points them to onUserAttributesChange, but the current expo-superwall event surface does not define or dispatch that callback: I checked upstream src/SuperwallEventCallbacks.ts and src/internal/superwallEventBridge.ts, and the callback list/switch only includes the existing paywall, subscription, log, purchase, and custom-callback events. Following this quickstart would therefore compile against a nonexistent callback (or never fire if forced through types); please document the supported Expo path or add the bridge before referencing it here.

Useful? React with 👍 / 👎.

</Note>
:::

You do this by passing an attributes dictionary or object to the SDK:

:::ios
<CodeGroup>
Expand Down Expand Up @@ -106,9 +126,40 @@ function UserProfile() {

## Usage

This is a merge operation, such that if the existing user attributes dictionary
This is a merge operation, such that if the existing user attributes
already has a value for a given property, the old value is overwritten. Other
existing properties will not be affected. To unset/delete a value, you can pass `nil`
for the value.
existing properties will not be affected.

:::ios
To unset/delete a user attribute, pass `nil` for that attribute name:

```swift Swift
Superwall.shared.setUserAttributes(["profilePic": nil])
```
:::

:::android
To unset/delete a user attribute, pass `null` for that attribute name:

```kotlin Kotlin
Superwall.instance.setUserAttributes(mapOf("profilePic" to null))
```
:::

:::flutter
The Flutter SDK accepts non-null user attribute values. It does not currently support deleting an attribute by passing `null`.
:::

:::expo
To unset/delete a user attribute, pass `null` for that attribute name. `undefined` keys are ignored before they cross the Expo bridge.

```tsx React Native
await update({
profilePic: null,
});
```

Nullable user attributes require `expo-superwall` 1.0.5 or later.
:::

You can reference user attributes in [audience filters](/dashboard/dashboard-campaigns/campaigns-audience) to help decide when to display your paywall. When you configure your paywall, you can also reference the user attributes in its text variables. For more information on how to that, see [Configuring a Paywall](/dashboard/dashboard-creating-paywalls/paywall-editor-overview).
Loading