Hello 👋 How can we help?

App Users

Written by Konstantine
Updated 1 month ago

By default HelpCrunch SDK requires a user to enter his name before sending messages. You can disable this with following code:

ObjC:
[HelpCrunch customerNameRequired:NO]; // Defaults to YES
ObjC:
HelpCrunch.customerNameRequired(false) // Defaults to YES

Saving app user data to HelpCrunch is done by calling 

[HelpCrunch updateUser:completionHandler:]/ HelpCrunch.updateUser([:]) { succeeded, error in }.

Important note: Be sure to put a unique User ID string in withUserID method for all your users. Constructing empty users with no data will not work (you can have no use of an empty user you cannot identify after all).

ObjC:
NSDictionary *user = @{
  HC_UserNameAttributeName: @"Username",
  HC_UserEmailAttributeName: @"Email",
  HC_UserPhoneAttributeName: @"Phone",
  HC_UserCompanyAttributeName: @"Company",
  HC_UserIdAttributeName: @"UserId",
  HC_CustomDataAttributeName: @{
    @"CustomKey1": @"CustomObject1",
    @"CustomKey2": @"CustomObject2",
    @"CustomKey3": @"CustomObject3"
  }
};
[HelpCrunch updateUser:user completionHandler:^(BOOL succeeded, NSError *error) {}];
Swift:
let attributes = [HC_UserNameAttributeName: "Username",
                  HC_UserEmailAttributeName: "Email",
                  HC_UserPhoneAttributeName: "Phone",
                  HC_UserCompanyAttributeName: "Company",
                  HC_UserIdAttributeName: "UserId",
                  HC_CustomDataAttributeName: 
                     ["CustomKey1": "CustomObject1",
                      "CustomKey2": "CustomObject2",
                      "CustomKey3": "CustomObject3"]
]
HelpCrunch.updateUser(attributes) { succeeded, error in }

You can also pass a user data when initializing HelpCrunch in your application:

ObjC:
[HelpCrunch initForOrganization:@"YOUR_HELPCRUNCH_SUBDOMAIN"
withAttributes:@{
  HC_ApplicationIdAttributeName:@"YOUR_APP_ID",
  HC_ApplicationSecretAttributeName:@"YOUR_APP_SECRET",
  HC_UserAttributeName: user
}];
Swift:
HelpCrunch.initForOrganization("YOUR_HELPCRUNCH_SUBDOMAIN"
    withAttributes:
        [HC_ApplicationIdAttributeName:"YOUR_APP_ID",
         HC_ApplicationSecretAttributeName:"YOUR_APP_SECRET",
         HC_UserAttributeName:userName]) { succeeded, error in }

After you have added user’s data it will appear in your HelpCrunch admin account in chat with that user:

In addition to user’s name / email / and ID HelpCrunch lets you send additional attributes of your customers in custom data. With the HC_CustomDataAttributeName you can send any information about users you wish to track. Custom data is key/value pairs and can contain numbers, strings or boolean data. This feature will only work if you have your user have a HC_UserIdAttributeName:

NSDictionary *user = @{
  HC_UserIdAttributeName: @"UserId",
  HC_CustomDataAttributeName: @{
    @"CustomKey1": @"CustomObject1",
    @"CustomKey2": @"CustomObject2",
    @"CustomKey3": @"CustomObject3"
  }
};

[HelpCrunch updateUser:user completionHandler:^(BOOL succeeded, NSError *error) {}];

Custom data parameters will appear in chat with user at your HelpCrunch admin account just as same as main user attributes (name, email, user id):

Also you will be able to search or filter your users by custom data at the “Contacts” page. There are 5 types of custom data you can search by: integer, float, string, boolean, datetime (example Y-m-d H:i:s)

Did this answer your question?