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

    @available(*, deprecated, message: "Deprecated by ORTB")
    public var yearOfBirth: Int { get set }
  • This method set the year of birth value

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated by ORTB")
    public func setYearOfBirth(yob: Int)
  • Undocumented

    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

    @available(*, deprecated, message: "Deprecated by ORTB")
    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. Deprecated.

    Declaration

    Swift

    @available(*, deprecated, message: "This property is deprecated. In the upcoming major release, the property will be removed.")
    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

    @available(*, deprecated, message: "This property is deprecated.  This is an exchange-specific property.")
    public var userCustomData: String?
  • Placeholder for User Identity Links. The data from this property will be added to usr.ext.eids

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated. This property will be removed in future releases. Please, use Targeting.setExternalUserIds(_:﹚ instead.")
    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
  • This value forces SDK to choose targeting info of the winning bid

    Declaration

    Swift

    public var forceSdkToChooseWinner: Bool

External User Ids

  • Sets the external user ID.

    Declaration

    Swift

    public func setExternalUserIds(_ externalUserIds: [ExternalUserId])
  • Retrieves the external user IDs in a dictionary format suitable for use in JSON.

    Declaration

    Swift

    public func getExternalUserIds() -> [[String : Any]]?
  • This method allows to save External User Id

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated. SDK doesn't support storing External User IDs in application storage. This method will be removed in future releases.")
    public func storeExternalUserId(_ externalUserId: ExternalUserId)
  • This method allows to get all External User Ids

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated. SDK doesn't support storing External User IDs in application storage. This method will be removed in future releases.")
    public func fetchStoredExternalUserIds() -> [ExternalUserId]?
  • This method allows to get External User Id by passing respective ‘source’ string as param

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated. This method will be removed in future releases.")
    public func fetchStoredExternalUserId(_ source: String) -> ExternalUserId?
  • This method allows to remove specific External User Id by passing respective ‘source’ string as param

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated. This method will be removed in future releases.")
    public func removeStoredExternalUserId(_ source: String)
  • This method allows to remove all the External User Ids

    Declaration

    Swift

    @available(*, deprecated, message: "Deprecated. This method will be removed in future releases.")
    public func removeStoredExternalUserIds()

SharedId

  • When true, the SharedID external user id is added to outgoing auction requests. App developers are encouraged to consult with their legal team before enabling this feature.

    See Targeting.sharedId for details.

    Declaration

    Swift

    public var sendSharedId: Bool
  • A randomly generated Prebid-owned first-party identifier

    Unless reset, SharedID remains consistent throughout the current app session. The same id may also persist indefinitely across multiple app sessions if local storage access is allowed. SharedID values are NOT consistent across different apps on the same device.

    Note

    SharedId is only sent with auction requests if Targeting.sendSharedId is set to true.

    Declaration

    Swift

    public var sharedId: ExternalUserId { get }
  • Resets and clears out of local storage the existing SharedID value, after which Targeting.sharedId will return a new randomized value.

    Declaration

    Swift

    public func resetSharedId()

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 Deprecated.

    Declaration

    Swift

    @available(*, deprecated, message: "This property is deprecated. In the upcoming major release, the property will be removed.")
    public var locationPrecision: Int?
  • Objective-C API Deprecated.

    Declaration

    Swift

    @available(*, deprecated, message: "This method is deprecated. In the upcoming major release, the method will be removed.")
    public func setLocationPrecision(_ newValue: NSNumber?)
  • Objective-C API Deprecated.

    Declaration

    Swift

    @available(*, deprecated, message: "This method is deprecated. In the upcoming major release, the method will be removed.")
    public func getLocationPrecision() -> NSNumber?

Location and connection information

  • CLLocationCoordinate2D. See CoreLocation framework documentation.

    Declaration

    Swift

    public var coordinate: NSValue?

Arbitrary ORTB Configuration

  • Sets the global-level OpenRTB configuration string.

    Declaration

    Swift

    public func setGlobalORTBConfig(_ ortbConfig: String?)

    Parameters

    ortbObject

    The global-level OpenRTB configuration string to set. Can be nil to clear the configuration.

  • Returns the global-level OpenRTB configuration string.

    Declaration

    Swift

    public func getGlobalORTBConfig() -> String?
  • 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

    @available(*, deprecated, message: "This method is deprecated. In the upcoming major release, the method will be removed.")
    public func setCustomParams(_ params: [String : String]?)

    Parameters

    params

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

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

    Declaration

    Swift

    @available(*, deprecated, message: "This method is deprecated. In the upcoming major release, the method will be removed.")
    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. Deprecated.

  • 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]