Skip to content

Event Handlers

If you want to handle ADvantage events, you need to implement the delegation methods. Extending our AdvantageDelegate class.

advantage:didFailWithError

This method will be called in any error case such as, no internet connection, connection/timeout, license issues and etc. The String msg will contain the error message which you can log into the logcat to trace the problem!

Swift
func advantage(_ advantage: ADvantage, didFailWithError error: String?) {...}
Objective-c

objective-c - (void)advantage:(ADvantage *)advantage didFailWithError:(NSString *)error {...}

advantageDidClose

This method will be called when an ad is completely closed!

Swift
func advantageDidClose(_ advantage: ADvantage) {...}
Objective-c
- (void)advantageDidClose:(ADvantage *)advantage {...}

advantage:didLoad

This method will be called when the ad request was completed. This callback contains an status which is an enumerator and could have the following values:

  • AVLoadedWithAd - Ad loaded successfully.
  • AVLoadedWithoutAd - There is no campaign available at the moment.
Swift
func advantage(_ advantage: ADvantage, didLoad state: AVLoadedState)
Objective-c
- (void)advantage:(ADvantage advantage didLoad:(AVLoadedState)state {...}

advantage:didExpandTo

This method will be called when an modal view is created (it will be triggered by the advertisement)

Swift
func advantage(_ advantage: ADvantage, didExpandTo rect: CGRect) {...}
Objective-c
- (void)advantage:(ADvantage *)advantage didExpandTo:(CGRect)rect {...}

advantage:didResizeTo

This method will be called when the ad space changes its size e.g. height change (it will be triggered by the advertisement)

Swift
func advantage(_ advantage: ADvantage, didResizeTo rect: CGRect) {...}
Objective-c
- (void)advantage:(ADvantage *)advantage didResizeTo:(CGRect)rect {...}

advantage:didUpdateLayoutTo

This method will be called when the ad space changes its position and/or size change (it will be triggered by the advertisement)

Swift
func advantage(_ advantage: ADvantage, didUpdateLayoutTo rect: CGRect) {...}
Objective-c
- (void)advantage:(nonnull ADvantage *)advantage didUpdateLayoutTo:(CGRect)rect {...}

advantage: notifyWithMessage / notifyWithDictionary

These methods are reserved for custom external plugins and future use cases.

Swift
func advantage(_ advantage: ADvantage, notifyWithMessage message: String?) {...}
func advantage(_ advantage: ADvantage, notifyWith dic: [AnyHashable : Any]) {...}
Objective-c
- (void)advantage:(ADvantage *)advantage notifyWithMessage:(NSString *)message {...}
- (void)advantage:(ADvantage *)advantage notifyWithDictionary:(NSDictionary *)dic {...}