Skip to content

User Profiling

NearIT creates an anonymous profile for every user of your app. You can choose to add data to user profile. This data will be available inside recipes to allow the creation of user targets.

Add User-data to NearIT

You can set user data with this method:

manager.setUserData("name", value: "John")
[manager setUserDataWithKey:@"name" value:@"John"];

If you want to set a date as a value, you have to use the format "MM-DD-YYYY".

Please remember: you will need to use the "Settings> Data Mapping" section of NearIT to configure the data fields to be used inside recipes.

If you want to set a multiple choice data point:

manager.setUserData("interests", multiValue: [
        "food" : true,
        "drink" : true,
        "exercise" : false
[manager setUserDataWithKey:@"interests" multiValue: @{
                                @"food" : @YES,
                                @"drink" : @YES,
                                @"exercise" : @NO}];

WARNING: With multiple choice data points you should always provide an object with values for all the keys, even keys whose value did not change. Keys missing from the object will have their value overridden by false.

You can delete the value for a certain user data point, passing null as the value for its key:

manager.setUserData("gender", value: nil)
manager.setUserData("interests", multiValue: nil)
[manager setUserDataWithKey:@"gender" value:nil];
[manager setUserDataWithKey:@"multiKey" multiValue:nil];

Fetch User-data from NearIT

You can get the current user data with this method:

manager.getUserData { (dataPoints, error) in
    dataPoints?.forEach({ (key: String, value: Any) in
        if let multiValue = value as? Dictionary<String, Bool> {
            // this is a multi choice user data
        } else if let stringValue = value as? String {
            // this is everything else
[manager getUserDataWithCompletionHandler:^(NSDictionary<NSString *,id> * _Nullable userData, NSError * _Nullable error) {
    id value = [userData objectForKey:@"MY_USER_DATA_KEY"];
    if ([value isKindOfClass:[NSDictionary class]]) {
        // this is a multi choice user data
    } else if ([value isKindOfClass:[NSString class]]) {
        // this is everything else

Save the Profile ID!

If you can, we recommend you to store the NearIT profileID in your CRM database for two main reasons:

  • it allows you to link our analytics to your users
  • it allows to associate all the devices of an user to the same NearIT profile.

You probably have a sign in system in your app, you should request the profile ID from NearIT before the user signs in:

manager.profileId { (profileId, error) in
    // Code for store the profileId in your CRM
[manager profileIdWithCompletionHandler:^(NSString * _Nullable profileId, NSError * _Nullable error) {
    // Code for store the profileId in your CRM

If you detect that your user already has a NearIT profile ID in your CRM database (i.e. after a sign in), you should pass the profile ID to NearIT:

manager.setProfile(id: "your remote NearIT profile ID")
[manager setProfileId:@"your remote NearIT profile ID"];

Whenever a users signs out from your app, you should reset the NearIT profileID:

manager.resetProfile { (profileId, error) in
    // ...
[manager resetProfileWithCompletionHandler:^(NSString * _Nullable profileId, NSError * _Nullable error) {
    // ...


You can opt-out a profile and its device:

manager.optOut { (success) in
    // ...
[manager optOutWithCompletionHandler:^(BOOL success) {
    // ...

If the opt-out call is successful all the user-data and trackings will be deleted and the SDK will cease to work (the user's devices will not receive further notifications).