# CENativeAd

## Overview

`CENativeAd` is used to request and manage native ad, which contains many parameters for building custom UI with `CEMediaView`.

## Interface

### `placement`

#### Declaration

```
@property (nonatomic, copy, readonly, nonnull) NSString * placement;
```

#### Discussion

Placement id which is used to require ad.

### `title`

#### Declaration

```
@property (nonatomic, copy, readonly, nullable) NSString * title;
```

#### Discussion

An optional string describing the title of the native ad.

### `subTitle`

#### Declaration

```
@property (nonatomic, copy, readonly, nullable) NSString * subTitle;
```

#### Discussion

An optional string describing the subtitle of the native ad.

### `callToAction`

#### Declaration

```
@property (nonatomic, copy, readonly, nullable) NSString * callToAction;
```

#### Discussion

An optional string describing the call to action slogan of the native ad. This is usually used to decorate the call-to-action button.

### `icon`

#### Declaration

```
@property (nonatomic, strong, readonly, nullable) CEAdImage * icon;
```

#### Discussion

A `CEAdImage` object, which is used to get the icon image of the native ad.

### `body`

#### Declaration

```
@property (nonatomic, copy, readonly, nullable) NSString * body;
```

#### Discussion

An optional string describing the main description of the native ad.

### `adToken`

#### Declaration

```
@property (nonatomic, strong, nullable) NSString * adToken;
```

#### Discussion

A random identifier string generated by SDK.

### `eventDelegate`

#### Declaration

```objectivec
@property (nonatomic, weak, nullable) id<CENativeAdEventDelegate> eventDelegate;
```

#### Discussion

Delegate which is notified by SDK when `CENativeeAd` triggered the ad event.

### `ad`

#### Declaration

```
@property (nonatomic, strong, readonly, nullable) Ad * ad;
```

#### Discussion

An `Ad` object containing data of the loaded ad.

### `coverImagePath`

#### Declaration

```
@property (nonatomic, strong, readonly, nullable) NSString * coverImagePath;
```

#### Discussion

The path to the file of the cover image of the loaded ad if the loaded ad has video content.

### `- registerViewForInteraction:withViewController:`

#### Declaration

```
- (void) registerViewForInteraction:(nonnull UIView *)view
                 withViewController:(nonnull UIViewController *)viewController;
```

#### Parameters

| name           | description                                            |
| -------------- | ------------------------------------------------------ |
| view           | A widget used to handle tap gesture for ad engagement. |
| viewController | The view controller containing the `view` parameter.   |

#### Discussion

This method is used to register custom widget for ad engagement. SDK add a tag gesture recognizer to `view` passed in to redirect user to langing page.

### `- registerViewForInteraction:withViewController:withClickableViews:`

#### Declaration

```
- (void) registerViewForInteraction:(nonnull UIView *)view
                 withViewController:(nonnull UIViewController *)viewController
                 withClickableViews:(nonnull NSArray *)clickableViews;
```

#### Parameters

| name           | description                                          |
| -------------- | ---------------------------------------------------- |
| view           | The container view for widgets.                      |
| viewController | The view controller containing the `view` parameter. |
| clickableViews | Widgets to handle ad engagement.                     |

#### Discussion

This method is used to register a series of custom widgets for ad engagement. SDK add tag gesture recognizers to `clickableViews` passed in to redirect users to langing page.

### `- loadAdInstantWithInfo:`

#### Declaration

```objectivec
- (BOOL)loadAdInstantWithInfo:(nonnull CERequestInfo *)info
                        error:(NSError **)error;
```

#### Parameters

| name  | description                                                             |
| ----- | ----------------------------------------------------------------------- |
| info  | `CERequestInfo` instance used to specify the parameters for ad request. |
| error | `NSError` instance used to specify the error for ad request.            |

#### Discussion

Start loading ad content process synchronously, and it will ignore the timeout in CERequestInfo.

### `- loadAdAsyncWithInfo:`

#### Declaration

```objectivec
- (void)loadAdAsyncWithInfo:(nonnull CERequestInfo *)info
                reqDelegate:(id<CENativeAdRequestDelegate>)reqDelegate;
```

#### Parameters

| name        | description                                                             |
| ----------- | ----------------------------------------------------------------------- |
| info        | `CERequestInfo` instance used to specify the parameters for ad request. |
| reqDelegate | id\<CENativeAdRequestDelegate> instance that receive request ad event.  |

#### Discussion

Start loading ad content process asynchronously.

`[CENativeAdRequestDelegate nativeAdDidLoad:]` is invoked if an ad is ready before timeout; otherwise, `[CENativeAdRequestDelegate nativeAd:didFailWithError:]` is invoked.

### `- hasVideoContent`

#### Declaration

```
- (BOOL) hasVideoContent;
```

#### Return Value

`YES` if the loaded ad is a video ad; otherwise, `NO`;

### `- getTotalFileSize`

#### Declaration

```
- (long long)getTotalFileSize;
```

#### Return Value

The total size of the creative files downloaded for this ad.
