iOS MoPub SDK Native Ads Support

564 views 2018-05-10 Ofer Garnett 0

 

Introduction

The purpose of this to document is to describe the steps needed in order to add YouAppi native ads support via MoPub iOS SDK.

Requirements

  • YouAppi’s Partner access token. The app access token is a unique identifier that is used by YouAppi to identify your app.
  • YouAppi-MoPub native ads Zip file. The Zip file is an iOS Framework allowing to show YouAppi’s demand using MoPub SDK.
  • MoPub SDK.

Instructions

  • Make sure MoPub SDK is added to your app. Instructions can be found at: https://github.com/mopub/mopub-android-sdk

  • Add YouAppi’s framework to your project, by dragging the folder: YouAppiMoPubNative.framework from the downloaded ZIP file to your app frameworks folder on XCode.

  • On XCode under the target of your app, make sure that the framework is added to both: Embedded Binaries and Linked Frameworks and Libraries.

 

  • Change to YES inside the build settings under the option ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES.
  • Change to YES inside the build settings under the option DEFINES_MODULE.
  • On your app target, to to: Build Phases and add a Run Script. Past the following code to the Run Script:

    APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
     
    # This script loops through the frameworks embedded in the application and
    # removes unused architectures.
    find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
    do
    FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
    FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
    echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
     
    EXTRACTED_ARCHS=()
     
    for ARCH in $ARCHS
    do
    echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
    lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
    EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
    done
     
    echo "Merging extracted architectures: ${ARCHS}"
    lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
    rm "${EXTRACTED_ARCHS[@]}"
     
    echo "Replacing original executable with thinned version"
    rm "$FRAMEWORK_EXECUTABLE_PATH"
    mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
     
    done
    It should look like:
  • On MoPub platform on Networks tab, add a new network for YouAppi:
  • On the popup that opens choose to add a Custom Native Network.
  • Name your new network (YouAppi might be a good name) and fill other relevant details.
  • On field CUSTOM EVENT CLASS enter the value: YouAppiNativeCustomEvent. It should look like:
  • Set your access token and ad unit id on field CUSTOM EVENT CLASS DATA. The value should look like: {“accessToken”: “e700f511-0e76-455c-bd0e-aaaaaaaaaaaa”, “adUnitId”: “your ad unit id”}. The access token is the partner access token you received from YouAppi. The ad unit id can be your MoPub ad unit ID or any other arbitrary name you would like to give to this placement.
  • Make sure to add YouAppi network as a source to your order/line item.

Test

  • Load your app section that contains native ads, and make sure you get native ads from YouAppi network.