Set Application Specific Attributes

Ability to set custom fields 

You can add custom strings, numbers and date variables. The information you set on each user can later be used to segment the users and create personalized dynamic push messages.

For example:

  • Add a user's first name to create personal push messages: " Hi John, we are...."
  • Add a user's birthday and use it to create a periodic birthday campaign to congratulate users on their birthday
  • Add a user's level in the game and use it to segment the users according to the level they have reached in your game

 

Objective-C

[[Appoxee shared] setDateValue:[NSDate date] forKey:@"key" withCompletionHandler:^(NSError * _Nullable appoxeeError, id _Nullable data) {

	if (!appoxeeError) {

		// Operation was successful.
	}
}];

[[Appoxee shared] setNumberValue:@(1.01) forKey:@"key" withCompletionHandler:^(NSError * _Nullable appoxeeError, id _Nullable data) {

	if (!appoxeeError) {

		// Operation was successful.
	}
}];

[[Appoxee shared] incrementNumericKey:@"key" byNumericValue:@(1.6) withCompletionHandler:^(NSError * _Nullable appoxeeError, id _Nullable data) {

	if (!appoxeeError) {

		// Operation was successful.
	}
}];

[[Appoxee shared] setStringValue:@"string" forKey:@"key" withCompletionHandler:^(NSError * _Nullable appoxeeError, id _Nullable data) {

	if (!appoxeeError) {

		// Operation was successful.
	}
}];

[[Appoxee shared] fetchCustomFieldByKey:@"CustomFieldKey" withCompletionHandler:^(NSError *appoxeeError, id data) {

	if (!appoxeeError && [data isKindOfClass:[NSDictionary class]]) {

		NSDictionary *dictionary = (NSDictionary *)data;
		NSString *key = [[dictionary allKeys] firstObject];
		id value = dictionary[key]; // can be of the following types: NSString || NSNumber || NSDate
	}

	// If there wan't an error, and data object is nil, then value doesn't exist on the device.
}];

 

Swift

 Appoxee.shared()?.setDateValue(NSDate(), forKey: "key", withCompletionHandler: { (appoxeeError, data) in
    
    if appoxeeError == nil {
     
        // Operation was successful.
    }
})

Appoxee.shared()?.setNumberValue(2, forKey: "key", withCompletionHandler: { (appoxeeError, data) in
    
    if appoxeeError == nil {
        
        // Operation was successful.
    }
})

Appoxee.shared()?.incrementNumericKey("key", byNumericValue: 1, withCompletionHandler: { (appoxeeError, data) in
    
    if appoxeeError == nil {
        
        // Operation was successful.
    }
})

Appoxee.shared()?.setStringValue("string", forKey: "key", withCompletionHandler: { (appoxeeError, data) in
    
    if appoxeeError == nil {
        
        // Operation was successful.
    }
})

Appoxee.shared()?.fetchCustomFieldByKey("key", withCompletionHandler: { (appoxeeError, data) in
    
    if appoxeeError == nil {
        
        if let dictionary = data as? NSDictionary {
            
            if let key = data?.allKeys.first {
                
                let value = dictionary.objectForKey(key)
            }
        }
    }
    
    // If there wan't an error, and data object is nil, then value doesn't exist on the device.
})