Adding Custom Values - adform/adform-ios-sdk GitHub Wiki

Adding custom values to Adform Advertising SDK

Publisher id is set globally using the main AdformSDK class and setPublisherId:andCustomData: method. Custom data is an optional parameter and you can pass nil to this method. However, if you want to target your users more accurately you should use the "custom data" parameter. It is a NSDictionary object containing key-value pairs (e.g. {"gender":"male"}) and is set globally to all ad requests. This parameter should be set before loading any ads because after a successful request to the server (with this parameter) "custom data" cannot be modified (you can still set it if you haven't done it before loading the ads). The best place to set the "custom data" parameter is application:didFinishLaunchingWithOptions: application delegate method. The example code below shows you how to set the "custom data" parameter:

Swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    //Create custom data parameter dictionary, we are using literal definition for this, but you can use any other definition as well
    let customData = ["gender": "male", "age": "20"]
            
    //Set AdformSDK custom data parameter
    AdformSDK.setPublisherId(PublisherId, andCustomData: customData)
    
    return true
}
Objective-C
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    //Create custom data parameter dictionary, we are using literal definition for this, but you can use any other definition as well
    NSDictionary *customData = @{@"gender": @"male", @"age": @"20"};
		
    //Set AdformSDK custom data parameter
    [AdformSDK setPublisherId:PublisherID andCustomData:customData];
    	
    return YES;
}
⚠️ **GitHub.com Fallback** ⚠️