Appylar is an SDK framework created by Appylar that provides ad-serving capabilities for iOS mobile applications.
Implementation Guide for Developers:
Appylar is a lightweight and user-friendly SDK for integrating ads into iOS applications, developed by Appylar. With this SDK, developers can easily integrate Appylar Ads into any type of iOS app
Appylar offers multiple ad types and provides developers with the flexibility to place ads anywhere within their application. The ad types available with Appylar are banners and interstitials.
- Appylar requires a minimum targeted version of iOS 12.0 or later.
To use Appylar Ads in your application, you need to follow these steps. Please note that additional implementation steps may be required based on your specific use case:
Adding Pods to an Xcode project
- Open a terminal window, and $ cd into your project directory.
- Create a Podfile. This can be done by running $ pod init.
- Add a CocoaPod by specifying pod '$Appylar' on a single line inside your target block.
target ‘App Name’ do pod 'Appylar' end
- Save your Podfile.
- Run $ pod install
- Open the MyApp.xcworkspace that was created. This should be the file you use everyday to create your app.
Before proceeding with Appylar Ads integration, ensure that the Pods directory is available in your project. Once confirmed, you can import the necessary class into your UIViewController class
import UIKit
import Appylar
- To implement Appylar Ads in your iOS application, create an extension of UIViewController() and override its viewDidLoad() method. Additionally, implement the AppylarDelegate protocol within this extension. If you already have an application subclass in your project, you can use that instead.
import UIKit
import Appylar
class ViewController: UIViewController{
Override func viewDidLoad(){
super.viewDidLoad()
//Attach callback listeners for SDK before initialization
AppylarManager.setEventListener(delegate: self,bannerDelegate: self,interstitialDelegate: self)
//Here ‘setEventListener’ is a method for AppylarManager
//Initialization
……
}
}
//Attach callbacks for initialization
extension ViewController: AppylarDelegate {
func onInitialized() {
//Callback for successful initialization
}
func onError(error: String) {
//Callback for error thrown by SDK
}
}
- Initialize SDK with configuration:
import UIKit
import Appylar
class ViewController: UIViewController{
Override func viewDidLoad(){
super.viewDidLoad()
//Attach callback listeners for SDK before initialization
AppylarManager.setEventListener(delegate: self,bannerDelegate: self,interstitialDelegate: self)
//Here ‘setEventListener’ is a method for AppylarManager
//Initialization
AppylarManager.Init(
app_Key: "<YOUR_APP_KEY>"?? “”, //APP KEY provided by console for Development use
Adtypes: [AdType.BANNER, AdType.INTERSTITIAL], //Types of Ads to integrate
orientations: [Orientation.PORTRAIT, Orientation.LANDSCAPE], //Supported orientations for Ads
testmode: true // ‘True’ for development and ‘False’ for production,
)
}
}
3.To further customize the Appylar Ads, you can use the setParameters() function after a valid session exists or after intialization.
Override func viewDidLoad(){
super.viewDidLoad()
//Attach callback listeners for SDK before initialization
AppylarManager.setEventListener(delegate: self,bannerDelegate: self,interstitialDelegate: self)
//Here ‘setEventListener’ is a method for AppylarManager
//Initialization
AppylarManager.Init(
app_Key: "<YOUR_APP_KEY>"?? “”, //APP KEY provided by console for Development use
Adtypes: [AdType.BANNER, AdType.INTERSTITIAL], //Types of Ads to integrate
orientations: [Orientation.PORTRAIT, Orientation.LANDSCAPE], //Supported orientations for Ads
testmode: true // ‘True’ for development and ‘False’ for production,
)
AppylarManager.setParameters(dict: [
"banner_height" : self.selectedHeightOfBanner != nil ? ["\(String(self.selectedHeightOfBanner!))"] : nil, // Height is given by user [“50”,”90]
"age_restriction" : self.selectedAge != nil ? ["\(String(self.selectedAge!))"] : nil //Age is given by user[“12”,”15”,”18”]
])
}
- To integrate the BannerView component into your design, you need to prepare a view from the storyboard and set it to the BannerView type. Follow these steps:
- Drag a view from the library to your UIViewController.
- In the Attribute Inspector, set the class to BannerView and the module to Appylar.
- Create an outlet of type BannerView in your UIViewController to link it with the storyboard view.
@IBOutlet weak var bannerView: BannerView!
- Implement callback for banners.
//Attach callbacks for banner.
func onNoBanner(){
//Callback for when there is no Ad to show.
}
func onBannerShown() {
//Callback for Ad shown.
}
- Check Ad availability and show the Ad.
For better performance and check the availability of ads you cancanShowAd()
function.
if BannerView.canShowAd(){
// showAd function with the value of placement
self.bannerView.showAd(placement: txtfieldEnterPlacement.text ?? "" )
// showAd function without placement parameter
self.bannerView.showAd()
}
The parameter placement is optional, and it is up to the developer to decide whether to pass it or not.
- To hide the banner.
bannerView.hideBanner()
- Make your
ViewController
of typeInterstitialViewController
.
class ViewController: InterstitialViewController
- Implement callbacks for Interstitial.
//Attach callbacks for interstitial.
func onNoInterstitial(){
//Callback for when there is no Ad to show.
}
func onInterstitialShown() {
//Callback for Ad shown.
}
func onInterstitialClosed() {
//Callback for close event of interstitial
}
- Check Ad availablity and show the Ad.
For better performance and check the availability of ads you cancanShowAd()
function.
if InterstitialViewController.canShowAd(){
// showAd function with the value of placement
self.bannerView.showAd(placement: txtfieldEnterPlacement.text ?? "" )
// showAd function without placement parameter
self.bannerView.showAd()
}
The parameter placement is optional, and it is up to the developer to decide whether to pass it or not.
- For lock the orientation of interstitial in your
AppDelegate
and override a function in it.
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return AppylarManager.supportedOrientation
}
- For initialization
import UIKit
import Appylar
class ViewController: InterstitialViewController{
Override func viewDidLoad() {
super.viewDidLoad()
//Attach callback listeners for SDK before initialization
AppylarManager.setEventListener(delegate: self,bannerDelegate: self,interstitialDelegate: self)
//Here ‘setEventListener’ is a method for AppylarManager
//Initialization
AppylarManager.Init(
app_Key: "<YOUR_APP_KEY>"?? “”, //APP KEY provided by console for Development use ["OwDmESooYtY2kNPotIuhiQ"]
Adtypes: [AdType.BANNER, AdType.INTERSTITIAL] //Types of Ads to integrate
orientations: [Orientation.PORTRAIT, Orientation.LANDSCAPE], //Supported orientations for Ads
testmode: true // ‘True’ for development and ‘False’ for production,
)
}
}
- For orientation lock of interstitial:
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return AppylarManager.supportedOrientation
}
- Implements for both the types:
import UIKit
import Appylar
class ViewController: InterstitialViewController {
@IBAction func btnShowBannerDidTapped(_ sender: UIButton) {
if BannerView.canShowAd(){
// showAd function with the value of placement
self.bannerView.showAd(placement: txtfieldEnterPlacement.text ?? "" )
// showAd function without placement parameter
self.bannerView.showAd()
}
}
@IBAction func btnHideBannerDidTapped(_ sender: UIButton) {
self.bannerView.hideBanner()
self.view.layoutIfNeeded()
}
@IBAction func btnShowIntersitialDidTapped(_ sender: UIButton) {
if InterstitialViewController.canShowAd(){
// showAd function with the value of placement
self.bannerView.showAd(placement: txtfieldEnterPlacement.text ?? "" )
// showAd function without placement parameter
self.bannerView.showAd()
}
}
}
//Attach callbacks for Initialization.
extension ViewController : AppylarDelegate {
func onInitialized() {
Print("onInitialized() ")
}
func onError(error : String) {
Print("onError() - \(error)")
}
}
//Attach callbacks for banner.
extension ViewController: BannerViewDelegate{
func onNoBanner() {
Print("onNoBanner()")
}
func onBannerShown() {
Print("onBannerShown()")
}
}
//Attach callbacks for interstitial.
extension ViewController: InterstitialDelegate{
func onNoInterstitial() {
Print("onNoInterstitial()")
}
func onInterstitialShown() {
Print("onInterstitialShown()")
}
func onInterstitialClosed() {
Print("onInterstitialClosed()")
}
}