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.
To import the MediafyAppLovinMAXAdapter into your iOS project, open your project's Podfile and add the following line to your app's target:
MediafyAppLovinMAXAdapter
pod 'MeidafySDK' pod 'MediafyAppLovinMAXAdapter'
Then, from the command line, run:
pod install --repo-update
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>
Follow the integration instructions to add the SDK to your app.
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.
In order to integrate AdMob native ads with Mars adapter, follow these steps:
Import MediafyAppLovinMAXAdapter.
import MediafyAppLovinMAXAdapter
Create a MANativeAdLoader with adUnitID.
adUnitID
let nativeAdLoader = MANativeAdLoader(adUnitIdentifier: adUnitId)
Configure the MANativeAdLoader.
nativeAdLoader.nativeAdDelegate = self
Create MediafyNativeParameters with required assets, native event trackers, context, and placement types. The following example requests: CTA text, title, icon, image, rating, and description.
MediafyNativeParameters
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
Create a MediafyAppLovinExtras and set it up with MediafyNativeParameters created in the previous step.
MediafyAppLovinExtras
let extras = MediafyAppLovinExtras(nativeParameters: parameters)
Set local extra parameter.
nativeAdLoader.setLocalExtraParameterForKey(MediafyAppLovinExtras.key, value: extras)
Create a layout for your ad according to AppLovin MAX documentation. Bind the subviews using unique tag IDs with an instance of MANativeAdViewBinder.
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)
Load the ad.
nativeAdLoader.loadAd(into: maNativeAdView)