iOS

The CrystalExpress MoPub Adapter allows MoPub publishers to add CrystalExpress as a Custom Ad Network within the MoPub platform.

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

MoPub ad unit

AD format from CrystalExpress

Banner or Medium

Card AD

Rewarded Video

Rewarded Video AD

Interstitial

Splash AD

Native

Native AD

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

Before you start add CrystalExpress as Custom network, you have to integrate MoPub SDK by following the instructions on the MoPub website.

NECESSARY STEPS:

  • Get CrystalExpress SDK and Crystal ID.

  • Integrate the CrystalExpress SDK.

  • Add CrystalExpress MoPub Adapter into project.

  • Configure MoPub to mediate CrystalExpress.

Get CrystalExpress SDK and Crystal ID

Please contact your Intowow account manager. We will provide the right version of SDK and Crystal ID according to 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

Find ce-[premium|lite]-[global|cn]-[version].a and add it to your project via Build Phases -> Link Binary With Libraries in project setting of Xcode.

Step 3

Add header files to project.

Step 4

Make sure that 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.

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

Add CrystalExpress MoPub Adapter into project

Step 1

Contact Intowow account manager for CrystalExpress MoPub Adapter and sample code.

Step 2

Unzip CrystalExpress_MoPub_Demo_iOS.zip, and add files under folder CrystalExpress_MoPub_Plugin (under MoPubDemo/MoPubDemo/) to your project according to following different propose.

  • For Banner:

    Banner/CEMPCardCustomEvent.h Banner/CEMPCardCustomEvent.m Common/UIView+CELayoutAdditions.h Common/UIView+CELayoutAdditions.m

  • For Native:

    Native/CEMPNativeCustomEvent.h Native/CEMPNativeCustomEvent.m Native/CEMPNativeAdRenderer.h Native/CEMPNativeAdRenderer.m Native/CEMPNativeAdAdapter.h Native/CEMPNativeAdAdapter.m Common/UIView+CELayoutAdditions.h Common/UIView+CELayoutAdditions.m

  • For Interstitial:

    Interstitial/CEMPInterstitialCustomEvent.h Interstitial/CEMPInterstitialCustomEvent.m

  • For Rewarded Video:

    RewardedVideo/CEMPRewardedVideoCustomEvent.h RewardedVideo/CEMPRewardedVideoCustomEvent.m

If you are still having issues, please check out the sample code within download folder.

Configure MoPub to mediate CrystalExpress

Step 1

Log in to your MoPub account and register your application on your account dashboard. 1. Click Networks tab. 2. Click Add a Network button.

Step 2

  1. Click Custom Native Network.

Step 3

  1. Add CrystalExpress into Title edit box.

  2. Add the Custom Event Classes for iOS:

    • Banner ad: enter CEMPCardCustomEvent

    • Native ad: enter CEMPNativeCustomEvent

    • Interstitial ad: enter CEMPInterstitialCustomEvent

    • Rewarded video ad: enter CEMPRewardedVideoCustomEvent

  3. For each unit, you will need to add a JSON object with the following keys:

    • placement_id (required; JSON String): Please contact intowow account manager for this.

    • default_title (optional; JSON String; Native ad only): Default string for ad title.

    • default_mainText (optional; JSON String; Native ad only): Default string for ad main text.

    • default_CTAText (optional; JSON String; Native ad only): Default string for call to action text.

Step 4

Request ad follow by the instructions for Banner Integration, Native Ads Integration, Interstitial Ads Integration, Rewarded video Ads Integration from MoPub.

The Layout of CrystalExpress AD

In MoPub custom event, our SDK will keep the aspect ratio of creatives and try to fit the ad view that you bind to MoPub.

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.

Last updated