Applovin SDK for monetization of smartphone is an another better alternative for the app developers. Recently I got a project and my Project manager asks me to integrate different ad networks that are available for smartphone app monetization. So when I started integrating Applovin SDK, I comfortably integrated popover ads, but had some tough ask when adding a banner ad. In this post we are going to learn that how can we integrate a banner ad using the Applovin SDK for IOS.
Once you are done with its integration setup like adding frameworks, adding key in info.plist file. We can start adding code to our files. Though you can add banner in.xib file too, and it’s an easy process. But I will add it programatically,
Import two files in your ViewController.h file
Then create an instance of ALAdView class, we named it as adView. Create one more instance of ALAd and named it cachedAda this is the ad we got from the server and will display in our adView.
Add declaration of ALAdLoadDelegate, that we are going to implement.
Now open up your ViewController.m and in its viewDidLoad and call loadNextAd method of ALSdk shared instance.
// Indicates that no ads are currently eligible for your device & location.
// Unable to reach AppLovin; the user’s device likely has poor connectivity.
Above didLoadAd will get called when ad was received from the server, so we assign ad received from the server to our cachedAd instance.Then we allocate our adView instance with the frames of the locations where we want to show our ad, we are showing it in the bottom of the screen.
To add our cachedAd to adView, we will use render method and that will render our Applovin ad to the adView and finally we will add our adView as a subview to our main view.
didFailToLoadAdWithError will get called when there was no ad or internet connection is not available to connect to server.
Run your project, and if everything goes ok then the project will compile without any error. Go to your Applovin dashboard and you will see your app listed there. NOTE: It will take some time for app to be appeared in dashboard.
You will not see any ad during test mode as it is turned off by default. You have to turn it on from Applovin dashboard. Shown in the picture
Run your project again and you will see Applovin ads displayed.
NOTE: It will take some time to display ad when you turn test mode on in the dashboard