Mars SDK - AppLovin

Integration

The integration of Mars SDK with AppLovin MAX necessitates that the publisher possesses an AppLovin account and has previously incorporated the AppLovin SDK into their application.

See the AppLovin Integration Documentation for the AppLovin integration details.

Cocoapods

To import the MediafyAppLovinMAXAdapter into your iOS project, open your project's Podfile and add the following line to your app's target:

pod 'MeidafySDK'
pod 'MediafyAppLovinMAXAdapter'

Then, from the command line, run:

pod install --repo-update

Configure SKAdNetwork

To support Mars network, update your app's Info.plist file to add the keys:

<key>SKAdNetworkItems</key>
<array>
  <dict>
    <key>SKAdNetworkIdentifier</key>
    <string>ejvt5qm6ak.skadnetwork></string>
  </dict>
</array>

Initialize Mars SDK

Follow the integration instructions to add the SDK to your app.

Integration of banner and interstitial ads

Banner and Interstitial formats don't require any additional effort. The mediation engine of GMA SDK will manage everything according to the Custom Network and Custom events setup. See the AdOps Guide for the details.

Integration of Native ads

In order to integrate AdMob native ads with Mars adapter, follow these steps:

Step 1

Import MediafyAppLovinMAXAdapter.

import MediafyAppLovinMAXAdapter

Step 2

Create a MANativeAdLoader with adUnitID.

let nativeAdLoader = MANativeAdLoader(adUnitIdentifier: adUnitId)

Step 3

Configure the MANativeAdLoader.

nativeAdLoader.nativeAdDelegate = self

Step 4

Create MediafyNativeParameters with required assets, native event trackers, context, and placement types. The following example requests: CTA text, title, icon, image, rating, and description.

let cta = MediafyNativeAssetData(type: .ctatext)
cta.length = 15
    
let title = MediafyNativeAssetTitle(length: 90)
title.required = true
    
let icon = MediafyNativeAssetImage(minimumWidth: 50, minimumHeight: 50)
icon.type = .Icon
    
let image = MediafyNativeAssetImage()
image.required = true
image.width = 1200
image.height = 627
image.type = .Main
    
let description = MediafyNativeAssetData(type: .description)
description.required = true
description.length = 150
    
let rating = MediafyNativeAssetData(type: .rating)
    
let parameters = MediafyNativeParameters()
parameters.assets = [cta, title, icon, image, rating, description]
    
let eventTracker = MediafyNativeEventTracker(
    event: .Impression,
    methods: [.Image, .js]
)
    
parameters.eventtrackers = [eventTracker]
parameters.context = .Social
parameters.placementType = .FeedContent
parameters.contextSubType = .Social

Step 5

Create a MediafyAppLovinExtras and set it up with MediafyNativeParameters created in the previous step.

let extras = MediafyAppLovinExtras(nativeParameters: parameters)

Step 6

Set local extra parameter.

nativeAdLoader.setLocalExtraParameterForKey(MediafyAppLovinExtras.key, value: extras)

Step 7

Create a layout for your ad according to AppLovin MAX documentation. Bind the subviews using unique tag IDs with an instance of MANativeAdViewBinder.

let binder = MANativeAdViewBinder { builder in
    builder.iconImageViewTag = 1
    builder.titleLabelTag = 2
    builder.bodyLabelTag = 3
    builder.advertiserLabelTag = 4
    builder.callToActionButtonTag = 5
}
    
maNativeAdView.bindViews(with: binder)

Step 8

Load the ad.

nativeAdLoader.loadAd(into: maNativeAdView)

Contact us today

to enjoy endless opportunities!

Contact Us
+

Contact Us