Skip to content

Management5Exceptions/ProjectManagement

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

98 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Integration Of Appylar For iOS

Appylar is an SDK framework created by Appylar that provides ad-serving capabilities for iOS mobile applications.

Implementation Guide for Developers:

  1. About Appylar
  2. Ad Types
  3. General Requirements
  4. Implementation
  5. Sample Codes

About Appylar

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

Built With

Ad Types

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.

General Requirements

  • Appylar requires a minimum targeted version of iOS 12.0 or later.

Implementation

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:

Pod Installation

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.

Add Appylar

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

Back To Top

Setup the configuration for your App and Listeners

  1. 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
        }
}
  1. 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”] 
        ])  
     }

Back To Top

Implementation of Banner

  1. 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!
  1. 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.  
   }
  1. Check Ad availability and show the Ad.
    For better performance and check the availability of ads you can canShowAd() 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.

  1. To hide the banner.
   bannerView.hideBanner()

Back To Top

Add Interstitial Ads

  1. Make your ViewController of type InterstitialViewController.
   class ViewController: InterstitialViewController
  1. 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
   }
  1. Check Ad availablity and show the Ad.
    For better performance and check the availability of ads you can canShowAd() 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.

  1. 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
      }

Back To Top

Sample Codes

  1. 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, 
			)
     	}
}
  1. For orientation lock of interstitial:
  func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
           return AppylarManager.supportedOrientation
  }
  1. 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()")
    }
}

Back To Top

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published