<img src="https://img.shields.io/badge/%20-ENTERPRISE-B10031" style="float:left"/><br /> <img src="https://img.shields.io/badge/iOS-V4-009727?logo=apple" style="float:left"/><br />

You can listen for ad events by assigning a delegate to the JWP `adDelegate` property. These events are surfaced using the following method.



<br />

The `player` is the instance of `JWPlayer` which has emitted the event. The event is an instance of `JWAdEvent` which supplies the following information:

  • Client: This is the ad client being used to present the ad. This is represented as a `JWAdClient` enumeration value.

  • Type: This is the type of event. This is represented as a `JWAdEventType` enumeration value.

<br />

The <a href="https://docs.jwplayer.com/players/docs/ios-event-properties-reference#jwaddelegate" target="_blank">properties</a> for the ad event can be queried using a subscript operator. The key for the subscript is a `JWEventKey` enumeration type. The subscript returns an optional type `Any?` that must be typecast into a type when retrieved.



<br />

If a property is not available, `nil` is returned.



For a list of types returned for each property, refer to the header documentation for `JWAdEventKey` or the [Event Properties Reference](🔗).

<br /> <hr />

## Requirement

  • JWPlayerKit 4.0.0+

<br /> <hr />

## Listen for ad events

When listening for ad events, you can use the `JWPlayerViewController` or `JWPlayerView`.

<br />

### JWPlayerViewController

When using the `JWPlayerViewController`, use the following steps to listen for ad events within your content:

  1. Create a subclass of `JWPlayerViewController`.

  2. Override the ad event method to listen for and handle ad events from the SDK.



<br /> <br />

### JWPlayerView

When using `JWPlayerView` and creating your own interface, use the following steps to listen for ad events within your content:

  1. Instantiate an instance of `JWPlayerView`.

  2. Assign a delegate object, which conforms to `JWAdDelegate`.

  3. Listen for ad events in your ad delegate.



<br />

</details>

<br />

(Script tags will be stripped)