Setting User Attributes

By setting user attributes, you can display information about the user on the paywall. You can also define rules in a campaign to determine which paywall to show to a user, based on their user attributes.

You do this by passing a [String: Any?] dictionary of attributes to Superwall.shared.setUserAttributes(_:):

let attributes: [String: Any] = [
  "apnsToken": user.apnsTokenString,
  "username": user.username,
  "profilePic": user.profilePicUrl
Superwall.shared.setUserAttributes(attributes) // (merges existing attributes)
NSDictionary *userAttributes = @{
  @"email" :
[[Superwall sharedInstance] setUserAttributes:userAttributes];// (merges existing attributes)

This is a merge operation, such that if the existing user attributes dictionary already has a value for a given property, the old value is overwritten. Other existing properties will not be affected.

You can reference user attributes in campaign rules 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.

In the future, you'll be able to use user attributes to email/notify users about discounts.

What’s Next