Appearance
Context Activation
This page provides documentation for two key functions in the Ringier Advertising SDK: activateContext and initView. These functions are essential for managing context-specific keywords and handling view changes within your iOS application, particularly when integrating banners or other ad placements.
Important Note: The context for these operations should always be a UIViewController. Ensure that the activation function is called once the data for the screen is loaded or when the user initiates a reload of the current screen, which should also trigger a rebuild of any associated banners.
swift
static func activateContext(keywords: RingierAd.Keywords)Description
Activates the context with context-specific keywords, optionally including a correlator and context URL.
Parameters
- keywords: RingierAd.Keywords – The context-specific keywords to activate. Replaces all existing keywords.
- correlator: String? – (Optional) A unique identifier for correlating ad requests. Defaults to nil.
- contextUrl: String? – (Optional) A URL providing additional context for the ad request. Defaults to nil.
Usage Guidelines
- Call Timing: Call this function after the screen's data is loaded or when the user initiates a screen reload, ensuring banners are rebuilt with the updated context.
- Context Requirement: Must be called within a UIViewController.
- Keyword Management: The provided keywords replace all prior keywords. Use RingierAd.Keywords to define the new set.
- Optional Parameters: Use correlator to track specific ad requests and contextUrl to provide additional context, such as the current page's URL.
Example
swift
import RingierAdSDK
class MyViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Load data here...
// Activate context with keywords, correlator, and context URL
let keywords = RingierAd.Keywords(/* your keywords here */)
RingierAd.activateContext(keywords: keywords, correlator: RingierAdCorrelator.generate(), contextUrl: "https://example.com/page")
}
func reloadScreen() {
// Reload data...
// Reactivate context and rebuild banners
let updatedKeywords = RingierAd.Keywords(/* updated keywords */)
RingierAd.activateContext(keywords: updatedKeywords, correlator: RingierAdCorrelator.generate(), contextUrl: nil)
// Rebuild banners as needed
}
}
