Targeting

@objcMembers
public class Targeting : NSObject

A class that manages targeting information for ads.

This class provides properties and methods for setting and retrieving user-specific targeting information, such as user ID, gender, and custom data. It also includes details for OMID (Open Measurement Interface Definition) partner and supports managing user identity links and custom extensions.

  • A shared instance of the Targeting class.

    Declaration

    Swift

    public static var shared: Targeting

OMID Partner

  • The name of the OMID partner.

    Declaration

    Swift

    public var omidPartnerName: String?
  • The version of the OMID partner.

    Declaration

    Swift

    public var omidPartnerVersion: String?

User Information

  • Indicates user birth year.

    Declaration

    Swift

    public var yearOfBirth: Int { get set }
  • This method set the year of birth value

    Declaration

    Swift

    public func setYearOfBirth(yob: Int)
  • Objective C API

    Declaration

    Swift

    public func getYearOfBirth() -> NSNumber
  • This method clears year of birth value set by the application developer

    Declaration

    Swift

    public func clearYearOfBirth()
  • Indicates the end-user’s gender.

    Declaration

    Swift

    public var userGender: Gender { get set }
  • String representation of the users gender, where “M” = male, “F” = female, “O” = known to be other (i.e., omitted is unknown)

    Declaration

    Swift

    public func userGenderDescription() -> String?
  • Indicates the customer-provided user ID, if different from the Device ID.

    Declaration

    Swift

    public var userID: String? { get set }
  • Buyer-specific ID for the user as mapped by the exchange for the buyer.

    Declaration

    Swift

    public var buyerUID: String?
  • Optional feature to pass bidder data that was set in the exchange’s cookie. The string must be in base85 cookie safe characters and be in any format. Proper JSON encoding must be used to include “escaped” quotation marks.

    Declaration

    Swift

    public var userCustomData: String?
  • Placeholder for User Identity Links. The data from this property will be added to usr.ext.eids

    Declaration

    Swift

    public var eids: [[String : AnyHashable]]?
  • Placeholder for exchange-specific extensions to OpenRTB.

    Declaration

    Swift

    public var userExt: [String : AnyHashable]?

COPPA

  • Objective C analog of subjectToCOPPA

    Declaration

    Swift

    public var coppa: NSNumber? { get set }
  • Integer flag indicating if this request is subject to the COPPA regulations established by the USA FTC, where 0 = no, 1 = yes

    Declaration

    Swift

    public var subjectToCOPPA: Bool? { get set }

GDPR

  • The boolean value set by the user to collect user data

    Declaration

    Swift

    public var subjectToGDPR: Bool? { get set }
  • Objective-C API

    Declaration

    Swift

    public func setSubjectToGDPR(_ newValue: NSNumber?)
  • Objective-C API

    Declaration

    Swift

    public func getSubjectToGDPR() -> NSNumber?

GDPR Consent

  • The consent string for sending the GDPR consent

    Declaration

    Swift

    public var gdprConsentString: String? { get set }

TCFv2

  • The consent string for purposes consent as per TCFv2.

    Declaration

    Swift

    public var purposeConsents: String? { get set }
  • Purpose 1 - Store and/or access information on a device

    Declaration

    Swift

    public func getDeviceAccessConsent() -> Bool?
  • Returns whether the user has consented to access device data as an NSNumber.

    Declaration

    Swift

    public func getDeviceAccessConsentObjc() -> NSNumber?
  • Returns the user’s consent for a specific purpose by index.

    Declaration

    Swift

    public func getPurposeConsent(index: Int) -> Bool?
  • Checks if access to device data is allowed.

    Declaration

    Swift

    public func isAllowedAccessDeviceData() -> Bool

External User Ids

  • Array of external user IDs.

    This property holds the external user IDs associated with the user.

    Declaration

    Swift

    public var externalUserIds: [ExternalUserId]
  • This method allows to save External User Id in the User Defaults

    Declaration

    Swift

    public func storeExternalUserId(_ externalUserId: ExternalUserId)
  • This method allows to get All External User Ids from User Defaults

    Declaration

    Swift

    public func fetchStoredExternalUserIds() -> [ExternalUserId]?
  • This method allows to get External User Id from User Defaults by passing respective ‘source’ string as param

    Declaration

    Swift

    public func fetchStoredExternalUserId(_ source: String) -> ExternalUserId?
  • This method allows to remove specific External User Id from User Defaults by passing respective ‘source’ string as param

    Declaration

    Swift

    public func removeStoredExternalUserId(_ source: String)
  • This method allows to remove all the External User Ids from User Defaults

    Declaration

    Swift

    public func removeStoredExternalUserIds()
  • Undocumented

    Declaration

    Swift

    public func getExternalUserIds() -> [[AnyHashable : Any]]?

Application Information

  • This is the deep-link URL for the app screen that is displaying the ad. This can be an iOS universal link.

    Declaration

    Swift

    public var contentUrl: String?
  • App’s publisher name.

    Declaration

    Swift

    public var publisherName: String?
  • ID of publisher app in Apple’s App Store.

    Declaration

    Swift

    public var sourceapp: String?
  • App store URL for an installed app

    Declaration

    Swift

    public var storeURL: String? { get set }
  • Domain name of the app

    Declaration

    Swift

    public var domain: String?
  • The itunes app id for targeting

    Declaration

    Swift

    public var itunesID: String?
  • The application location for targeting

    Declaration

    Swift

    public var location: CLLocation?
  • The application location precision for targeting

    Declaration

    Swift

    public var locationPrecision: Int?
  • Objective-C API

    Declaration

    Swift

    public func setLocationPrecision(_ newValue: NSNumber?)
  • Objective-C API

    Declaration

    Swift

    public func getLocationPrecision() -> NSNumber?

Location and connection information

  • CLLocationCoordinate2D. See CoreLocation framework documentation.

    Declaration

    Swift

    public var coordinate: NSValue?

Public Methods

  • Adds a parameter to the parameter dictionary with a specified name.

    Declaration

    Swift

    public func addParam(_ value: String, withName: String?)

    Parameters

    value

    The value of the parameter.

    withName

    The name of the parameter. If nil, the parameter is not added.

  • Sets custom parameters by adding each key-value pair to the parameter dictionary.

    Declaration

    Swift

    public func setCustomParams(_ params: [String : String]?)

    Parameters

    params

    A dictionary of parameters to set. If nil, no parameters are added.

  • Adds a custom parameter to the parameter dictionary with a prefixed name.

    Declaration

    Swift

    public func addCustomParam(_ value: String, withName: String?)

    Parameters

    value

    The value of the custom parameter.

    withName

    The name of the custom parameter. If nil, the parameter is not added.

  • Store location in the user’s section

    Declaration

    Swift

    public func setLatitude(_ latitude: Double, longitude: Double)

Access Control List (ext.prebid.data)

  • Adds a bidder to the access control list.

    Declaration

    Swift

    public func addBidderToAccessControlList(_ bidderName: String)

    Parameters

    bidderName

    The name of the bidder to add.

  • Removes a bidder from the access control list.

    Declaration

    Swift

    public func removeBidderFromAccessControlList(_ bidderName: String)

    Parameters

    bidderName

    The name of the bidder to remove.

  • Clears all bidders from the access control list.

    Declaration

    Swift

    public func clearAccessControlList()
  • Retrieves the current access control list.

    Declaration

    Swift

    public func getAccessControlList() -> [String]

    Return Value

    An array of bidder names in the access control list.

  • Access control list for external use.

    Declaration

    Swift

    public var accessControlList: [String] { get }

    Return Value

    An array of bidder names in the access control list.

Global User Data (user.ext.data)

  • Adds user data for a specified key.

    Declaration

    Swift

    public func addUserData(key: String, value: String)

    Parameters

    key

    The key for the user data.

    value

    The value to add for the specified key.

  • Updates user data for a specified key with a new set of values.

    Declaration

    Swift

    public func updateUserData(key: String, value: Set<String>)

    Parameters

    key

    The key for the user data.

    value

    The set of values to update for the specified key.

  • Removes user data for a specified key.

    Declaration

    Swift

    public func removeUserData(for key: String)

    Parameters

    key

    The key for the user data to remove.

  • Clears all user data.

    Declaration

    Swift

    public func clearUserData()
  • Retrieves all user data.

    Declaration

    Swift

    public func getUserData() -> [String : [String]]

    Return Value

    A dictionary mapping keys to arrays of values.

  • User data dictionary for external use.

    Declaration

    Swift

    public var userDataDictionary: [String : [String]] { get }

    Return Value

    A dictionary mapping keys to arrays of values.

Global User Keywords (user.keywords)

  • Adds a user keyword.

    Declaration

    Swift

    public func addUserKeyword(_ newElement: String)

    Parameters

    newElement

    The keyword to add.

  • Adds multiple user keywords.

    Declaration

    Swift

    public func addUserKeywords(_ newElements: Set<String>)

    Parameters

    newElements

    A set of keywords to add.

  • Removes a user keyword.

    Declaration

    Swift

    public func removeUserKeyword(_ element: String)

    Parameters

    element

    The keyword to remove.

  • Clears all user keywords.

    Declaration

    Swift

    public func clearUserKeywords()
  • Retrieves all user keywords.

    Declaration

    Swift

    public func getUserKeywords() -> [String]

    Return Value

    An array of user keywords.

  • Deprecated. Use getUserKeywords method instead.

    Declaration

    Swift

    @available(*, deprecated, message: "This property is deprecated. Please, use getUserKeywords method instead.")
    public var userKeywords: [String] { get }

Global Data (app.ext.data)

  • Deprecated. Use addAppExtData method instead.

    Declaration

    Swift

    @available(*, deprecated, message: "This method is deprecated. Please, use addAppExtData method instead.")
    public func addContextData(key: String, value: String)
  • Deprecated. Use updateAppExtData method instead.

    Declaration

    Swift

    @available(*, deprecated, message: "This method is deprecated. Please, use updateAppExtData method instead.")
    public func updateContextData(key: String, value: Set<String>)
  • Deprecated. Use removeAppExtData method instead.

    Declaration

    Swift

    @available(*, deprecated, message: "This method is deprecated. Please, use removeAppExtData method instead.")
    public func removeContextData(for key: String)
  • Deprecated. Use clearAppExtData method instead.

    Declaration

    Swift

    @available(*, deprecated, message: "This method is deprecated. Please, use clearAppExtData method instead.")
    public func clearContextData()
  • Deprecated. Use getAppExtData method instead.

    Declaration

    Swift

    @available(*, deprecated, message: "This method is deprecated. Please, use getAppExtData method instead.")
    public func getContextData() -> [String : [String]]
  • Deprecated. Use getAppExtData method instead.

    Declaration

    Swift

    @available(*, deprecated, message: "This property is deprecated. Please, use getAppExtData method instead.")
    public var contextDataDictionary: [String : [String]] { get }
  • Adds application-specific data for a specified key.

    Declaration

    Swift

    public func addAppExtData(key: String, value: String)

    Parameters

    key

    The key for the application data.

    value

    The value to add for the specified key.

  • Updates application-specific data for a specified key with a new set of values.

    Declaration

    Swift

    public func updateAppExtData(key: String, value: Set<String>)

    Parameters

    key

    The key for the application data.

    value

    The set of values to update for the specified key.

  • Removes application-specific data for a specified key.

    Declaration

    Swift

    public func removeAppExtData(for key: String)

    Parameters

    key

    The key for the application data to remove.

  • Clears all application-specific data.

    Declaration

    Swift

    public func clearAppExtData()
  • Retrieves all application-specific data.

    Declaration

    Swift

    public func getAppExtData() -> [String : [String]]

    Return Value

    A dictionary mapping keys to arrays of values.

Global Keywords (app.keywords)

  • Deprecated. Use addAppKeyword method instead.

    Declaration

    Swift

    @available(*, deprecated, message: "This method is deprecated. Please, use addAppKeyword method instead.")
    public func addContextKeyword(_ newElement: String)
  • Deprecated. Use addAppKeywords method instead.

    Declaration

    Swift

    @available(*, deprecated, message: "This method is deprecated. Please, use addAppKeywords method instead.")
    public func addContextKeywords(_ newElements: Set<String>)
  • Deprecated. Use removeAppKeyword method instead.

    Declaration

    Swift

    @available(*, deprecated, message: "This method is deprecated. Please, use removeAppKeyword method instead.")
    public func removeContextKeyword(_ element: String)
  • Deprecated. Use clearAppKeywords method instead.

    Declaration

    Swift

    @available(*, deprecated, message: "This method is deprecated. Please, use clearAppKeywords method instead.")
    public func clearContextKeywords()
  • Deprecated. Use getAppKeywords method instead.

    Declaration

    Swift

    @available(*, deprecated, message: "This method is deprecated. Please, use getAppKeywords method instead.")
    public func getContextKeywords() -> [String]
  • Deprecated. Use getAppKeywords method instead.

    Declaration

    Swift

    @available(*, deprecated, message: "This property is deprecated. Please, use getAppKeywords method instead.")
    public var contextKeywords: [String] { get }
  • Adds an application keyword.

    Declaration

    Swift

    public func addAppKeyword(_ newElement: String)

    Parameters

    newElement

    The keyword to add.

  • Adds multiple application keywords.

    Declaration

    Swift

    public func addAppKeywords(_ newElements: Set<String>)

    Parameters

    newElements

    A set of keywords to add.

  • Removes an application keyword.

    Declaration

    Swift

    public func removeAppKeyword(_ element: String)

    Parameters

    element

    The keyword to remove.

  • Clears all application keywords.

    Declaration

    Swift

    public func clearAppKeywords()
  • Retrieves all application keywords.

    Declaration

    Swift

    public func getAppKeywords() -> [String]

    Return Value

    An array of application keywords.

Internal Properties

  • Dictionary of parameters.

    Declaration

    Swift

    public var parameterDictionary: [String : String]