# iOS

The CrystalExpress DFP Custom Events allows DFP publishers to add CrystalExpress as a Custom Ad Network within the DFP platform.

CrystalExpress provides two ad formats for DFP mediation. The relationship between DFP ad unit and ad format in CrystalExpress is as following:

| DFP ad unit  | AD format from CrystalExpress |
| ------------ | ----------------------------- |
| Banner       | Card AD                       |
| Interstitial | Splash AD                     |

**NOTICE: The aspect ratio for CrystalExpress ad is 16:9, 4:3 or 1:1.**

Before adding CrystalExpress as Custom network, you have to integrate DFP SDK by following the instructions on the [DFP website](https://developers.google.com/mobile-ads-sdk/docs/dfp/ios/quick-start).

**NECESSARY STEPS:**

* Get CrystalExpress SDK and Crystal ID.
* Integrate the CrystalExpress SDK.
* Add CrystalExpress DFP Custom Event into project.
* Configure DFP to mediate CrystalExpress.

## Get CrystalExpress SDK and Crystal ID

Please contact your Intowow account manager. We will provide the appropriate version of SDK and Crystal ID to fit your needs.

## Integrate the CrystalExpress SDK.

### Step 1

Unzip the SDK package, and you could find static library, header files, and sample app.

### Step 2

Add `ce-[premium|lite]-[global|cn]-[version].a` to your project via **Build Phases** -> **Link Binary With Libraries** in the project setting of Xcode.

### Step 3

Add header files to project.

### Step 4

Make sure all of the following frameworks are added into Build Phases.

* Security.framework
* CFNetwork.framework
* MessageUI.framework
* MobileCoreServices.framework
* SystemConfiguration.framework
* AdSupport.framework
* libz.dylib
* libc++.dylib
* CoreTelephony.framework
* CoreMedia.framework
* libsqlite3.dylib
* AVFoundation.framework
* libicucore.dylib

### Step 5

Add `-ObjC` flag in **TARGETS** -> **Build Settings** -> **Linking** -> **Other Linker Flags**.

### Step 6

Copy `CrystalExpress.plist` to your project and set the Crystal\_Id value to Crystal ID you received from Intowow account manager.

### Step 7

Import `I2WAPI.h` in `AppDelegate.m`.\
Initialize SDK in `application:didFinishLaunchingWithOptions:` of `AppDelegate.m`:

```
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // init SDK
    [I2WAPI initWithVerboseLog:NO isTestMode:NO];
    return YES;
}
```

* Enable/disable debugging message from SDK with `initWithVerboseLog:(BOOL)`.
* Set SDK to test mode by `isTestMode:(BOOL)` for development.

### Step 8

iOS 9 and later versions block http connection by default. Since most of the redirect links of ads use HTTP protocol, we have to modify `Info.plist` in your project to allow HTTP connections.

```markup
<key>NSAppTransportSecurity</key>
<dict>
     <key>NSAllowsArbitraryLoads</key>
     <true/>
</dict>
```

## Add CrystalExpress DFP Custom Event into project

### Step 1

Contact Intowow account manager for CrystalExpress DFP Custom Event and sample code.

### Step 2

Unzip `ce-[premium|lite]-global-custom-event-SDKversion.zip`, and add files under `CustomEvents/Google/` to your project according to following different propose.

* For Banner:

  `Banner/CECustomEventCard.h`

  `Banner/CECustomEventCard.m`

  `Common/UIView+CELayoutAdditions.h`

  `Common/UIView+CELayoutAdditions.m`
* For Interstitial: `Interstitial/CECustomEventInterstitial.h`

  `Interstitial/CECustomEventInterstitial.m`

For further integration issues, please check the sample code within download folder.

## The Layout of CrystalExpress AD

In DFP Custom Event, our SDK will keep the aspect ratio of creatives and try to fit the ad view that you bind to DFP.

If the aspect ratio for the ad view to be bound and the creative are inconsistent, the return ad will be filled with black background to match the aspect ratio.

![](https://1252529651-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LGU_q6Cp7glylaa3ogy%2F-LGU_uDXyKLpZsKhgGZa%2F-LGU_vbp4I8vzyrFVs-Q%2FSorry%20bro.png?generation=1530612137464909\&alt=media)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://intowow.gitbook.io/crystalexpress-documentation-v3-x/mediation-guidelines/mediating-intowow/dfp/ios.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
