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, 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

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

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?

Location

  • The application location for targeting

    Declaration

    Swift

    public var location: CLLocation?

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.

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

Global Data (app.ext.data)

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

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