Implementing the IMA SDK in Android Applications

Suppose that one day you decide to create an application for children and try to make money on it. Since advertising is one of the easiest ways to monetize, then you have an obvious idea to add one of the advertising SDKs to the application and then only calculate the income. This could be the case if the app was aimed at an adult audience. If it is intended for use by minors, then a variety of legislative mechanisms are included that govern app stores.



When publishing the ivi kids app on Google Play, we faced a problem that our internal advertising SDK did not meet Google's requirementsand the app may have been removed from the store. Therefore, we turned off all ads, which made young users very happy, but the marketing department was chronically unhappy with the financial performance.



The most logical way out of the situation was to play ads that Google itself distributes using the Google Ad Manager service . And do it using the IMA SDK, which is also a Google product.



In this article I will talk about how we implemented the IMA SDK in ivi and ivi kids applications and what limitations we encountered.



Chips IMA SDK



I will not describe all the features and structure of the IMA SDK, since in any case the official documentation will be able to say much more about them .



What is the main feature of the IMA SDK? And why did it suit us? The IMA SDK can play VAST video ads . One of the possibilities of this format is the creation of nested ad wrappers, and the number of wrappers can formally be infinite. That is, to get to the real video, you need to run through all the wrappers in the chain.







The IMA SDK can run through this chain on its own if you simply insert a link to the first VAST file into it using the setAdTagUrl (String url) method .



val adsRequest = ImaSdkFactory.getInstance().createAdsRequest()
adsRequest.adTagUrl = advUrl


If you use this method, the developer's task is greatly simplified. But sometimes (including in our case) the application developer wants to collect its own advertising statistics, contained in the VAST files themselves. These files cannot be requested from the ad server more than once, since the ad server can send two different responses to the same request (this is the norm, ads should be constantly changing). In this case, the developer needs to collect all VASTs with pens, extract the data necessary for collecting statistics from there and generate a general VAST based on them, which can be fed to the IMA SDK using the setAdsResponce (String vast) method :



val adsResponce = “<VAST>..</VAST>” //xml,   VAST
adsRequest.adsResponse = adsResponce


Another useful feature of the IMA SDK is the ability to use the internal player of the application to play ads. To do this, you can implement the VideoAdPlayer interface and implement its methods in your player:



public interface VideoAdPlayer extends AdProgressProvider, VolumeProvider {
   void loadAd(AdMediaInfo var1, AdPodInfo var2);

   void playAd(AdMediaInfo var1);

   void pauseAd(AdMediaInfo var1);

   void stopAd(AdMediaInfo var1);

   void release();

   void addCallback(VideoAdPlayer.VideoAdPlayerCallback var1);

   void removeCallback(VideoAdPlayer.VideoAdPlayerCallback var1);
}


But even if the application does not have its own video player, or it cannot be used for some reason, the IMA SDK provides its own player based on ExoPlayer :



val adUiContainer: ViewGroup = view
val videoAdPlayer =  ImaSdkFactory.createSdkOwnedPlayer(context, adUiContainer)


IMA SDK limitations



Unfortunately, the UI of the IMA SDK is sad. Be prepared that your ad player will always look like this: It is







impossible to change any controls on the ad screen from the IMA SDK. You can only change their language:



val imaSdkSettings = ImaSdkFactory.getInstance().createImaSdkSettings()
imaSdkSettings.language = "ru"








Our situation was aggravated by the fact that ivi and ivi kids exist and are supported on a single code base. This means that with the help of build scripts, at the necessary moment from one code, you can assemble different applications with their own bells and whistles (icons, lines, pieces of code). This unified codebase for playing ads uses a proprietary engine that is a proven tool for making money for the company. With the implementation of the IMA SDK, this code could not be simply thrown away, since the application uses various ad formats, not just VAST.



The ivi ad interface looks completely different from the IMA SDK interface and cannot be adapted to it:







Therefore, the most obvious decision looked like the decision to leave our advertising engine ( NSD ) and simultaneously implement the IMA SDK, so that when an advertisement that contains links to Google servers arrives, it will use IMA, and for all other advertising - NSD, which can also play ads in the format VAST and run through the entire chain of wrappers, but does not meet the standards of Google Family Policy.





Currently, ads from Google and ads from other sources in the ivi application are displayed in different ways. In the ivi kids app for children, only ads from Google are targeted, so there videos are displayed only using the IMA SDK.



Outcome



IMA SDK is a simple and convenient tool for displaying video ads. If you are ready for the fact that the UI of the advertising player will not depend on you, then the IMA SDK is fine for you. If you need to monetize an Android app for kids with ads, then the easiest way is to use the native tool from Google - IMA SDK.






All Articles