White Paper

Ad SDK Integration for Mobile Publishers Media and Entertainment (M&E)

Table of Contents 01 Executive Summary 01 Introduction 03 Solution Overview

Executive Summary

This paper discusses integration of Ad SDK in . It highlights integration and monetization of apps; which are built using , ANE, Marmalade and Corona; through third-party Ad SDK.

Introduction

The mobile gaming industry is on the rise for ad networks manage the demand from their both and publishers. The market share advertiser partners and some of them also of mobile gaming stands at 16% of the total such demand from third-party ad networks. gaming revenue worldwide, which is estimated at €10.68 billion. In US, mobile gaming revenue The publisher partners need to integrate Ad is estimated at $3 billion. Game engines such SDK into their for enabling such ad as Unity and Unreal, rule the cross-platform and networks or exchanges to serve and place ads on mobile gaming and power some of the most the publishers’ app. popular around the globe. The publishers also include game publishers With growing acceptance or mobile gaming, or developers who generally their mobile more and more ad networks and ad exchanges gaming app on top of platforms partner with various mobile app and game such as Unity, ANE, Corona, and Marmalade. publishers to offer them ad inventory. Many such

01 against online competitors due to deficiency in engaging the customers, not positioning business for digital acceptance, lesser adoption of technology, minimal innovative efforts towards building convergent (offline or online) client model, or overcoming the shortfall of legacy pain points by introducing new solutions. sure that customers can view what they are looking for conveniently Although there are many dimension of user experience, it can be broadly classified into the following aspects: • Usability aspect o Easy navigation on the website This whitepaper intends to overcome common on Ad SDK integration for the games developed challenges and understand changes that such using engines such as Unity, ANE, Marmalade, o Easy adaption to the website and game publishers will need to make in their SDK and Corona. quicker product search for seamless integration with any Ad SDK. This o Search relevance whitepaper also captures the details around Challenges that game publishers and developers implementation and integration of wrappers or face: o Placing and arrangement of products plug-ins that can be used by the game publishers o Product categorization to integrate with mobile Ad SDKs. • Game publishers build their game app using any of the previously listed game engines. o Value addition and usefulness of the What is a game engine? content • In order to monetize their ad inventory, o Consistency and visual clarity A game engine is a framework designed developers need to integrate mobile ad for creating and developing games. Game network and ad exchange SDK or plug-ins • Sales aspect developers or publishers use them to create that are compatible to such game engines. o Customer assistance with product games for consoles, mobile devices, and personal • Game engines have partnership only selection process computers. Game engine technology is maturing with leading mobile ad networks and ad and becoming more user-friendly. Game exchanges leaving game publishers with very o Personalization Developers and Publishers are now being used limited options to monetize. for experiences targeted towards o Recommendation—up-sale/cross sale multiple platforms including mobile devices and • Game publishers prefer integrating with their o Promotion/discount web browsers. existing partner ad network or ad exchange, but such partners may not offer Ad SDKs • Ability to purchase seamlessly While there are many other game engines which are compatible to the game engines. popular among mobile game developers and o Upfront cost breakup publishers, this whitepaper highlights solution o No hidden cost

Global game engine market share

45% 17% 38%

Unity Closest competitor Others

Source: Unreleased McKinsey report

02 Unity: Solution Overview Unity is a flexible and powerful game development platform for creating multiplatform Technology as an enabler: 3D and 2D games and interactive experiences. Unity offers a complete ecosystem for anyone Technological evolution in mobility defines the who aims to build a business on creating high- best practices for integrating mobile ad networks end content and connecting to their most loyal or ad exchanges supporting varied ad formats and enthusiastic game players. Game publishers such as banner, interstitial, rich media, and video. and developers need to have Native plug-ins This section details the solution approach for included into their code to enable integration game developers and publishers on how they with partner Ad SDK. can update their SDK for ensuring monetization through ad integration and seamless integration Marmalade: of partner ad network with leading game engines such as Unity, Marmalade, Corona, and ANE. With Marmalade is a cross- some customization and workarounds, the same development engine built around the belief that solution helps integration with generic OpenGL- developers should be free to innovate, create, based Android and iOS game engines as well. and craft fantastic content for any audience on any device without compromising on Unity: performance or creative . Game publishers and developers need to implement Marmalade In Unity, game publishers and developers EDK (Extensions Development Kit) into their code, normally use scripts to create functionality but which allows integration with partner Ad SDK. they can also include code created outside Unity in the form of a plug-in. Corona: There are two kinds of plug-ins available for use Corona’s extensive API library enables everything in Unity—Managed plug-ins and Native plug-ins. from animation to networking with just a few lines of code. Managed plug-ins are managed .NET assemblies created with tools such as Visual Studio or Whether you’re building games or business apps, MonoDevelop. They contain only .NET code, you can see changes instantly in the Corona which means that they can’t access any features Simulator and can iterate extremely quickly. that are not supported by the .NET libraries. Game publishers and developers need to develop However, managed code is accessible to the and integrate Native plug-in using library or standard .NET tools that Unity uses to compile service provider to enable integration with scripts. There is, thus, a little difference in usage Solution Overview partner Ad SDK. between managed plug-in code and Unity script code, except for the fact that the plug-ins are ANE: compiled outside Unity and so the source may not be available. Adobe AIR is by design cross-platform and device-independent, but AIR applications can Native plug-ins is platform-specific native code still access the capabilities and of native libraries. They can access features such as OS platforms through AIR native extensions. A calls and third-party code libraries that would native extension enables you to use platform- otherwise not be available to Unity. However, specific features, reuse existing native libraries, these libraries are not accessible to Unity’s and achieve native-level speed for performance- tools in the way that managed libraries are. For sensitive code. Game publishers and developers example, if you forget to add a managed plug-in need to develop and integrate AIR Native file to the project, you will get standard compiler Extension (ANE) file to allow integration with partner Ad SDK.

03 error messages. If you do the same with a native plug-in, you will only see an error report when you try to run the project.

Implement Compile and Package Generate unique User Unity 4.5 wrapper/plugin the Plugin Publisher ID (Managed/Native) (SDK Plugin.unitypackage)

Navigate to Assets- Deploy on Android Select SDK Plugin. Open SDK in Unity Import Package- or iOS unity package Editor Custom Package

• Prerequisite: Game publisher and developer o Import all of the files for the plug-ins by will need to have Native plug-ins included selecting Import. Make sure to check for into their code that is required to allow any conflicts with files integration with partner Ad SDK.o Easy navigation on the website o To deploy on Android: Android 3.2 or higher • Implementation Approach: o To deploy on iOS: Xcode 5.1 or above o Use Unity 4.5o Search relevance

o Generate unique publisher ID or partner Marmalade: Ad SDK’s ad unit ID Marmalade lets publishers use familiar tools and o Implement a wrapper or plug-in a straightforward workflow to take their games (Managed plug-in or Native plug-in) and apps cross-platform. The Marmalade Hub is compatible wifth Unity intuitive and user-friendly GUI tool that acts as an interface to the functionality the SDK provides. o Compile and package the plug-in in SDKPlugin.unitypackage file Platform-specific APIs and extensions:

• integration Approach: Marmalade provides support for platform- specific features such as in-app purchasing or o Open your SDK project in the Unity editor online gaming by using extra APIs that wrap o Navigate to Assets -> Import Package -> the native SDK functionality on each platform. Custom Package These APIs provide a simpler way of accessing such features and as a bonus will take care of the o Select the SDKPlugin.unitypackage file required initialization, termination, and general housekeeping tasks required for using them.

04 Create Extension for Implement Set NDK_ROOT field Install Java SDK and iOS/Android using Extension for to the path of the Android NDK EDK Android Android NDK

Implement Open SDK in Unity Build Extension on Extension for iOS Editor Mac OS

Ship as Marmalade Package the subproject, a .mkf Extension project file

Call Extension Include Extension’s Include Subproject functions from header file in source in project’s MKB file source code

• Prerequisite: Game publisher and developer (alternatively, you can also check that the will need to implement Marmalade NDK_ROOT environment variable points Extensions Development Kit (EDK) into their to the path of the Android NDK) code that allows integration with partner Ad SDK. o Implement the extension for iOS: Building extensions for the iOS platform on • Implementation Approach: Windows is not supported and is only supported on the Mac OS. o Create extensions for iOS or Android using EDK: The Extensions Development o Build and package the extensions Kit (EDK) allows users to create new extensions. To create an extension you o Ship the extension as a marmalade need the native SDK and tools for each ‘subproject’, a .mkf project file platform you are targeting. For example, plus headers and source or library if you are creating it for Mac, you will implementations. need Mac + Xcode + iOS SDK for iOS. • Integration Approach:

o Implement the extension for Android: o Use of EDK extension is similar to using Before you start building an Android any out of the box abstraction layer (S3E) extension, you must ensure that you have API that comes with Marmalade the Java SDK and Android NDK’s installed. Also, ensure that the Dependency o Include the subproject in your project’s Checker in the Hub has the NDK_ROOT MKB file, for example, subprojects field set to the path of the Android NDK. { MyExtension }

05 o Include the extension’s header file in your In some cases, plug-ins cannot be written as source code shared libraries:

o Call extension functions from your source • On iOS, shared libraries are not supported, code so plug-ins must be static libraries (.a).

o When an extension function is called, • On Android, it’s often convenient to create it will call the implementation on the pure Java plug-ins (.jar). platform the app is running. Types of plug-ins: Corona:

Plug-ins allow you to extend the functionality of 1. Libraries: Library plug-ins are just Lua Corona. libraries. These can be used to wrap native functionality. These libraries are Development is done in Lua, a lightning-fast and namespaced with the prefix plug-in. easy to learn scripting language. Corona SDK allows you to publish for iOS, Android (including 2. Providers. Provider plug-ins are designed Android TV), Kindle, and 8 from to standardize functionality provided a single code base. Mac OS X and Windows by third-party service providers. You support is coming very soon (both are in private would never explicitly load these plug- beta). The Corona platform is built on industry ins through require. Instead, a wrapper standards including OpenGL, OpenAL, , interface loads them implicitly because , SQLite and various others. the wrapper depends on the provider for the underlying functionality. These Corona plug-ins leverage Lua’s module system. wrapper interfaces can be libraries (for In Lua’s module system, plug-ins are lazily loaded example, ads) or functions. by a corresponding call to the Lua function require. Typically, these plug-ins are just shared • Prerequisite: Game publisher or developer native libraries, which is supported on platforms will need to develop and integrate Native such as Mac (.dylib), Windows (.dll), and Android Plug-in using library or provider, which (.so). allows integration with partner Ad SDK. Developing a library plug-in is preferred here.

Create universal Build and Package Create Providers using Create a Plugin library for your your Corona Provider class plugin Ad SDK Plugin

• Implementation Approach: o This project has separate sub-folders for the platform-specific project files for each o Create a plug-in: When you create a target platform: iOS and Android plug-in, you can use the App project template to simplify the plug-in creation o There’s also a Corona folder that sits and testing project. After all, the plug-in alongside these folders that contain the itself is not executable and needs to run classical Corona project, for example, inside an actual application. main.lua. You can modify these files to test the Lua APIs that are offered by your plug-in

06 o For iOS plug-in development, you need o Provider plug-ins: Provider plug-ins are to modify the Plugin.xcodeproj also Lua modules, but you do not load them directly. Instead the wrapper library o Create universal library for your plug-in (or function) allows you to specify the o Build plug-ins on Lua’s module system, provider and then loads them for you. so they can come in three different In order for the provider to be loaded, flavors – 1. Pure Lua code, 2. Native code it needs to follow a specific namespace (recommended to build wrapper for convention. These libraries are prefixed partner Ad SDK) and 3. Hybrid of Lua and with CoronaProvider followed by the Native code name of the wrapper

o Providers can also be created in Lua o For game publishers or developers, it’s using the CoronaProvider class. You can recommended to use Native Library Plug- create your own provider types in Lua by in development and integration for AD subclassing CoronaProvider. SDK.

o Build and package your Ad SDK plug-in: ANE: Plug-ins should be submitted through a Native extensions for Adobe AIR are code bitbucket repo that will be shared with libraries that contains native code wrapped you. Prepare the directory structure, with an ActionScript API. Examples of native create metadata.json, .jar (for Android) extensions include making a and metadata.lua (for iOS) and submit the vibrate, integrating ad-networks, and in-app plug-in purchasing systems into your games. • Integration Approach: Native extensions for Adobe AIR provide o SDK: Plug-ins are hosted on Corona’s ActionScript APIs that provide you access to server. You can incorporate plug-ins by device-specific functionality programmed making an appropriate change in build. in native code. Native extension developers settings sometimes work with device manufacturers, and sometimes are third-party developers. o Enterprise: Native plug-ins can easily be added to your iOS or Android project. AIR Native Extension (ANE) Files: On iOS, plug-ins will be in the form of .a Native extension developers package a native (static library) files that needs to be linked extension into an ANE file. An ANE file is an into your app executable. On Android, archive file that contains the necessary libraries plug-ins can come in the form of .so and resources for the native extension. (shared library) or .jar files. These files should be in your projects libs directory As an AIR application developer, you use the ANE to ensure that the ant script sees them. file as follows:

o Library Plug-ins: Library plug-ins are • Include the ANE file in the application’s simply Lua modules where the module library path in the same way you include name is prefixed with plug-in. The prefix a SWC file in the library path. This action helps avoid namespace collisions with allows the application to reference the Corona libraries. These libraries should be extension’s ActionScript classes. loaded through Lua’s require function.

07 Note: When compiling your application, be sure • Package the ANE file with the AIR application to use dynamic linking for the ANE. If using Flash Builder, specify External on the ActionScript • Prerequisite: Game publisher and developer Builder Path Properties panel; if using the will need to develop and integrate AIR command line, specify -external-library-path. Native Extension (ANE) file to allow integration with partner Ad SDK.

User Air Developer Declare extension in Include ANE file in Package the app Tool (ADT) app descriptor file app library path to package an app

Ensure ANE file Specify the extension User a native installer supports app’s directory package type target device

• Implementation Approach: • Integration Approach:

o Declare the extension in your o Use a native installer package type application descriptor file o Specify the extension directory o Include the ANE file in your application’s library path o Make sure that the ANE file supports the application’s target device o Package the application Business-level benefits: o Include the ANE file in your application’s library path: To compile an application • Flexibility to integrate any partner ad that uses a native extension, include the network or ad exchange ANE file in your library path – using the ANE file with Flash Builder or with Flash • A plug-in or wrapper SDK compatible to the Professional. game engine of your choice

o Packaging an application that uses native • Scalable solution to include newer extensions: Use AIR Developer Tool (ADT) Interactive Advertising Bureau (IAB) mobile to package an application that uses native ad formats extensions. You cannot package the • Compatibility to VAST, Video Player Ad- application using Flash Professional CS5.5 Serving Interface Definition (VPAID), and or Flash Builder 4.5.1 Video Multiple Ad Playlist (VMAP) among others as per IAB standards

08 development. This whitepaper serves the Conclusion easy reference with implementation details to seamlessly integrate with preferred mobile Ad With the growing penetration of mobile gaming, SDK. For the specific use case and game engines game publishers and developers intent to described in this whitepaper, game publishers monetize their inventory by integrating their and developers are recommended to implement preferred partner mobile Ad Network or Ad and integrate: Exchange. Such game publishers either use leading game engines mentioned earlier or • Native plug-in for Unity OpenGL-based Android and iOS game engines to build their games and apps. Developers find • Extensions (EDK) for Marmalade it challenging to integrate with partner mobile • Native plug-ins using Library or Provider for Ad SDK, which don’t have readily available Corona wrapper or plug-in or API compatible to such game engine frameworks used in the game • Native Extensions for ANE

Cybage Software Pvt. Ltd. [An SEI-CMMI Level 5 & ISO 27001 Company]

HQ: Cybage Towers, Survey No 13A/ 1+2+3/1, Vadgaon Sheri, Pune 411014 | Tel: 91 20 6604 4700 | Fax: 91 20 6604 1701 Pune | Hyderabad | Gandhinagar | Seattle | New Jersey | San Francisco | Atlanta | Austin | London | Frankfurt | Amsterdam | Sydney www.cybage.com

© 2014. Cybage Software Ltd. All rights reserved. 09