AdzerkSDK

@objcMembers
public class AdzerkSDK : NSObject

The primary class used to make requests against the API.

  • The host to use for outgoing API requests. If not set, a default adzerk hostname will be used that is based on the default network ID. This must be set prior to making requests.

    Failing to set defaultNetworkID or host explicitly will result in a `fatalError`.
    
    Note that the defaultNetworkID-based subdomain will not change if a different networkID is
    supplied for a specific request.
    

    Declaration

    Swift

    public class var host: String! { get set }
  • Provides storage for the default network ID to be used with all placement requests. If a value is present here, each placement request does not need to provide it. Any value in the placement request will override this value. Useful for the common case where the network ID is contstant for your application.

    Declaration

    Swift

    public class var defaultNetworkId: Int? { get set }
  • Provides storage for the default site ID to be used with all placement requests. If a value is present here, each placement request does not need to provide it. Any value in the placement request will override this value. Useful for the common case where the network ID is contstant for your application.

    Declaration

    Swift

    public class var defaultSiteId: Int? { get set }
  • Setter for defaultNetworkId. Provided for Objective-C compatibility.

    Declaration

    Swift

    public class func setDefaultNetworkId(_ networkId: Int)
  • Setter for defaultSiteId. Provided for Objective-C compatibility.

    Declaration

    Swift

    public class func setDefaultSiteId(_ siteId: Int)
  • Initializes a new instance of AdzerkSDK with a keychain-based userKeyStore.

    Declaration

    Swift

    public convenience override init()
  • Initializes a new instance of AdzerkSDK. @param userKeyStore provide a value for this if you want to customize the way user keys are stored & retrieved. The default is ADZKeychainUserKeyStore.

    Declaration

    Swift

    public init(userKeyStore: ADZUserKeyStore, queue: DispatchQueue? = nil)
  • Requests placements with explicit success and failure callbacks. Provided for Objective-C compatibility. See requestPlacements:options:completion for complete documentation.

    Declaration

    Swift

    public func requestPlacements(_ placements: [ADZPlacement], options: ADZPlacementRequestOptions? = nil,
        success: @escaping (ADZPlacementResponse) -> (),
        failure: @escaping (Int, String?, NSError?) -> ())
  • Requests a single placement using only required parameters. This method is a convenience over the other placement request methods. @param div the div name to request @param adTypes an array of integers representing the ad types to request. The full list can be found at https://github.com/adzerk/adzerk-api/wiki/Ad-Types . @completion a callback block that you provide to handle the response. The block will be given an ADZResponse object.

    Declaration

    Swift

    public func requestPlacementInDiv(_ div: String, adTypes: [Int], completion: @escaping (ADZResponse) -> ())
  • Requests a single placement. @param placement the placement details to request @param completion a callback block that you provide to handle the response. The block will be given an ADZResponse object.

    Declaration

    Swift

    public func requestPlacement(_ placement: ADZPlacement, completion: @escaping (ADZResponse) -> ())
  • Requests multiple placements. @param placements an array of placement details to request @param completion a callback block that you provide to handle the response. The block will be given an ADZResponse object.

    Declaration

    Swift

    public func requestPlacements(_ placements: [ADZPlacement], completion: @escaping (ADZResponse) -> ())
  • Requests multiple placements with additional options. The options can provide well-known or arbitrary parameters to th eoverall request. @param placements an array of placement details to request @param options an optional instance of ADZPlacementRequestOptions that provide top-level attributes to the request @param completion a callback block that you provide to handle the response. The block will be given an ADZResponse object.

    Declaration

    Swift

    public func requestPlacements(_ placements: [ADZPlacement], options: ADZPlacementRequestOptions?, completion: @escaping (ADZResponse) -> ())
  • Posts custom properties for a user. @param userKey a string identifying the user. If nil, the value will be fetched from the configured UserKeyStore. @param properties a JSON serializable dictionary of properties to send to the UserDB endpoint. @param callback a simple callback block indicating success or failure, along with an optional NSError.

    Declaration

    Swift

    public func postUserProperties(_ userKey: String?, properties: [String : Any], callback: @escaping ADZResponseCallback)
  • Posts custom properties for a user. @param networkId the networkId for this request @param userKey a string identifying the user @param properties a JSON serializable dictionary of properties to send to the UserDB endpoint. @param callback a simple callback block indicating success or failure, along with an optional NSError.

    Declaration

    Swift

    public func postUserProperties(_ networkId: Int, userKey: String, properties: [String : Any], callback: @escaping ADZResponseCallback)
  • Returns the UserDB data for a given user. @param userKey a string identifying the user @param callback a simple callback block indicating success or failure, along with an optional NSError.

    Declaration

    Swift

    public func readUser(_ userKey: String?, callback: @escaping ADZUserDBUserResponseCallback)
  • Returns the UserDB data for a given user. @param networkId the networkId to use for this request @param userKey a string identifying the user @param callback a simple callback block indicating success or failure, along with an optional NSError.

    Declaration

    Swift

    public func readUser(_ networkId: Int, userKey: String, callback: @escaping ADZUserDBUserResponseCallback)
  • Adds an interest for a user to UserDB. @param userKey the current user key. If nil, the saved userKey from the configured userKeyStore is used. @param callback a simple success/error callback to use when the response comes back

    Declaration

    Swift

    public func addUserInterest(_ interest: String, userKey: String?, callback: @escaping ADZResponseCallback)
  • Adds an interest for a user to UserDB. @param interest an interest keyword to add for this user @param networkId the network ID for this action @param userKey the user to add the interest for @param callback a simple success/error callback to use when the response comes back

    Declaration

    Swift

    public func addUserInterest(_ interest: String, networkId: Int, userKey: String, callback: @escaping ADZResponseCallback)
  • Opt a user out of tracking. Uses the defaultNetworkId set on AdzerkSDK. @param userKey the user to opt out. If nil, the saved userKey from the configured userKeyStore is used. @param callback a simple success/error callback to use when the response comes back

    Declaration

    Swift

    public func optOut(_ userKey: String?, callback: @escaping ADZResponseCallback)
  • Opt a user out of tracking. @param networkId the network ID for this action @param userKey the user to opt out @param callback a simple success/error callback to use when the response comes back

    Declaration

    Swift

    public func optOut(_ networkId: Int, userKey: String, callback: @escaping ADZResponseCallback)
  • Retargets a user to a new segment. @param userKey the user to opt out @param brandId the brand this retargeting is for @param segmentId the segment the user is targeted to @param callback a simple success/error callback to use when the response comes back

    Declaration

    Swift

    public func retargetUser(_ userKey: String?, brandId: Int, segmentId: Int, callback: @escaping ADZResponseCallback)
  • Retargets a user to a new segment. @param networkId the network ID for this request @param userKey the user to opt out @param brandId the brand this retargeting is for @param segmentId the segment the user is targeted to @param callback a simple success/error callback to use when the response comes back

    Declaration

    Swift

    public func retargetUser(_ networkId: Int, userKey: String, brandId: Int, segmentId: Int, callback: @escaping ADZResponseCallback)
  • Sends a request to record an impression. This is a fire-and-forget request, the response is ignored. @param url a valid URL retrieved from an ADZPlacementDecision

    Declaration

    Swift

    public func recordImpression(_ url: URL)