Appearance
Delegate
The WelcomeAdBannerViewDelegate protocol defines methods for handling user interactions with the welcome ad banner.
swift
func welcomeAdView(_ view: WelcomeAdBannerView, didClickAction action: String, timestamp: TimeInterval?, payload: [String: Any]?)Called when the user interacts with the welcome ad banner by clicking a button.
Parameters:
- view: The WelcomeAdBannerView instance that triggered the interaction.
- action: A string indicating the type of action performed. Possible values are:
- "closeWelcomeAd": The user clicked a button to close the welcome ad. The application should remove or hide the ad.
- "scrollWelcomeAd": The user clicked a button to scroll to the application's content. The application should scroll to the relevant content view.
- timestamp: An optional TimeInterval representing the time of the interaction. payload: An optional dictionary containing additional data related to the interaction.
Usage:
Implement this method to handle user interactions, such as closing the ad or scrolling to content based on the action parameter.
Example
swift
extension ViewController: WelcomeAdBannerViewDelegate {
func welcomeAdView(_ view: WelcomeAdBannerView, didClickAction action: String, timestamp: TimeInterval?, payload: [String: Any]?) {
switch action {
case "closeWelcomeAd":
view.removeFromSuperview() // Close the ad
case "scrollWelcomeAd":
// Scroll to content (e.g., in a collection view or scroll view)
collectionView.scrollToItem(at: IndexPath(item: 0, section: 1), at: .top, animated: true)
default:
break
}
}
}
