Skip to main content

Create iOS Adaptor

Extend Base Adapter Class#

Create a custom adapter class in Swift with the naming convention as <AdaptorName>SDKAdapter

class <AdapterName>SDKAdapter: NSObject, MesonBaseSDKAdapter {
//Override the methods
}

Initialize the Custom Network SDK#

Override one of the initialization methods provided in the base adapter.

Asynchronous Initialization#

initOnSDKInit(), method is provided by MesonBaseSDKAdapter to initialize custom network SDK asynchronously. The method return type is void.

ParameterDescription
AdapterConfigurationAll the network related information required to initialize the custom network SDK. AdapterSDKConfiguration will have atleast one of the required credentials; Network (Account ID), App (App ID) or Ad Line (Placement ID).
MesonSdkInitializationListenerThis listener contains a single call back method onComplete(Error). Listener object should call onComplete() method with the null value if network SDK is initialized successfully or else pass Error object with the proper error message.
func initOnSDKInit(adapterSdkConfiguration: AdapterSdkConfiguration, sdkInitializedResultHandler: @escaping (Result<Bool, MesonAdapterError>) -> Void) {
// Write the code the initialize the SDK asynchronously.
}

Synchronous Initialization#

initOnAdLoad(), method is provided by MesonBaseSDKAdapter to initialize network SDK synchronously. The method return type is not void; it should return null if network SDK is initialized successfully or else Error object with the proper error message.

ParameterDescription
AdapterConfigurationAll the network related information required to initialize the custom network SDK. AdapterSDKConfiguration will have atleast one of the required credentials; Network (Account ID), App (App ID) or Ad Line (Placement ID).
func initOnAdLoad(adapterSdkConfiguration: AdapterSdkConfiguration) -> Result<Bool, MesonAdapterError>? {
// Write the code to initialize the SDK synchronously.
}

Set SDK Version#

getSDKVersion(), override this method to return custom network SDK version.
var networkSDKVersion: String {
// Return the SDK version
}

Manage Ad Lifecycle#

Create custom network SDK adapter classes per format with naming convention as AdapterNameFormatAdapter by extending the base format adapter classes.

Banner Ad#

To create a custom network SDK Adapter class for Banner format extend the MesonBaseBannerAdapter

Load Ad#

load(), override this method in MesonBaseBannerAdapter to load ad from the custom network SDK.

ParameterDescription
AdapterConfigurationAll the network related information required to initialize the custom network SDK. AdapterSDKConfiguration will have atleast one of the required credentials; Network (Account ID), App (App ID) or Ad Line (Placement ID).
MesonBannerAdapterListenerThis provides the ad lifecycle listener events.
func load(adapterConfiguration: AdapterAdConfiguration) {
// Write the code to load network sdk's banner ad
}

Return Banner Ad View#

getAdView(), override this method in the MesonBaseBannerAdapter to return custom network SDKs banner ad view.
func getAdView() -> UIView? {
return banner
}

Interstitial Ad#

To create a custom network SDK Adapter class for Interstitial format extend the MesonBaseInterstitialAdapter

Load Ad#

load(), override this method in MesonBaseBannerAdapter to load ad from the custom network SDK.

ParameterDescription
AdapterConfigurationAll the network related information required to initialize the custom network SDK. AdapterSDKConfiguration will have atleast one of the required credentials; Network (Account ID), App (App ID) or Ad Line (Placement ID).
MesonInterstitialAdapterListenerThis provides the ad lifecycle listener events.
func load(adapterConfiguration: AdapterAdConfiguration) {
// Write the code to load network sdk's interstitial ad
}

Ad Load Success#

isReady, override this property to verify whether custom network SDK has successfully loaded an ad. This method returns true if custom network SDK is ready to show the ad or else returns false.
var isReady: Bool {
return interstitial.isReady()
}

Show Ad#

show(), override this method to show interstitial or rewarded ad from the custom network SDK.
func show(from viewController: UIViewController) {
// Write the code to show the interstitial ad.
}

Rewarded Ad#

To create a custom network SDK Adapter class for Rewarded format extend the MesonBaseRewardedAdapter

Load Ad#

load(), override this method in MesonBaseBannerAdapter to load ad from the custom network SDK.

ParameterDescription
AdapterConfigurationAll the network related information required to initialize the custom network SDK. AdapterSDKConfiguration will have atleast one of the required credentials; Network (Account ID), App (App ID) or Ad Line (Placement ID).
MesonRewardedAdapterListenerThis provides the ad lifecycle listener events.
func load(adapterConfiguration: AdapterAdConfiguration) {
// Write the code to load network sdk's rewarded ad
}

Ad Load Success#

isReady, override this property to verify whether custom network SDK has successfully loaded an ad. This method returns true if custom network SDK is ready to show the ad or else returns false.
var isReady: Bool {
return rewarded.isReady()
}

Show Ad#

show(), override this method to show interstitial or rewarded ad from the custom network SDK.
func show(from viewController: UIViewController) {
// Write the code to show the rewarded ad.
}