Project Configuration
Change Configuration File
- Changed from
daro-service.jsontoios-daro-key.txt. - Info.plist: Set
DaroAppKey
ios-daro-key.txt can be downloaded from the DARO Dashboard.DaroAppKey can be found in the DARO Dashboard.Code Migration
SDK Initialization Changes
Show Previous Code - DaroAds non-reward SDK
Show Previous Code - DaroAds non-reward SDK
import DaroAds
// SDK initialization
DaroMobileAds.shared.logLevel = .debug
DaroMobileAds.shared.start {
print("SDK initialization complete")
}
Show Previous Code - DaroMAds reward SDK
Show Previous Code - DaroMAds reward SDK
import DaroMAds
// SDK initialization
DaroMMobileAds.shared.logLevel = .debug
DaroMMobileAds.shared.initialize {
print("SDK initialization complete")
}
non-reward app >> import Daro
reward app >> import DaroM
// SDK initialization (unified)
DaroAds.shared.logLevel = .debug
DaroAds.shared.userId = "user_id" // Optional
DaroAds.shared.initialized { error in
if let error = error {
print("SDK initialization failed: \(error)")
} else {
print("SDK initialization complete")
}
}
Ad Unit Creation Method Changes
Show Previous Code - DaroAds non-reward SDK
Show Previous Code - DaroAds non-reward SDK
// Dedicated structs for each ad type
let appOpenUnit = DaroAdAppOpenUnit(id: "ad_unit_id")
let bannerUnit = DaroAdBannerViewUnit(id: "ad_unit_id")
let interstitialUnit = DaroAdInterstitialUnit(id: "ad_unit_id")
let rewardedUnit = DaroAdRewardedUnit(id: "ad_unit_id")
let nativeUnit = DaroNativeAdUnit(id: "ad_unit_id")
Show Previous Code - DaroMAds reward SDK
Show Previous Code - DaroMAds reward SDK
// Format specification method
let appOpenUnit = DaroMAdUnit(adUnitID: "ad_unit_id", format: .appOpen)
let bannerUnit = DaroMAdUnit(adUnitID: "ad_unit_id", format: .banner)
let interstitialUnit = DaroMAdUnit(adUnitID: "ad_unit_id", format: .interstitial)
let rewardedUnit = DaroMAdUnit(adUnitID: "ad_unit_id", format: .rewarded)
let nativeUnit = DaroMAdUnit(adUnitID: "ad_unit_id", format: .native)
// Unified ad unit struct
let adUnit = DaroAdUnit(unitId: "ad_unit_id")
// Specify placement (optional)
let adUnit = DaroAdUnit(unitId: "ad_unit_id", placement: "main_screen")
Listener Method Changes
// Listeners commonly used across all ad types
ad.listener.onAdLoadSuccess = { ad, adInfo in
// Called when ad loads successfully
}
ad.listener.onAdLoadFail = { error in
// Called when ad load fails
}
ad.listener.onAdImpression = { adInfo in
// Called when ad is displayed
}
ad.listener.onAdClicked = { adInfo in
// Called when ad is clicked
}
// Set ad display listeners
(interstitialListener | rewardedAdListener | appOpenAdListener )
.onShown = { adInfo in
print("[DARO] Listener Sample Interstitial Ad shown: \(adInfo)")
}
(interstitialListener | rewardedAdListener | appOpenAdListener )
.onDismiss = { adInfo in
print("[DARO] Listener Sample Interstitial Ad dismissed: \(adInfo)")
}
(interstitialListener | rewardedAdListener | appOpenAdListener )
.onFailedToShow = { adInfo, error in
print("[DARO] Listener Sample Interstitial Ad failed to show: \(adInfo) \(error)")
}
rewardedAd.rewardedAdListener.onEarnedReward = { rewardItem, adInfo in
// Called when reward is earned
}
Ad Type-Specific Code Changes
Show Banner Ads
Show Banner Ads
Show Previous Code - DaroAds non-reward SDK
Show Previous Code - DaroAds non-reward SDK
let adUnit = DaroAdBannerViewUnit(id: "your_ad_unit_id")
let bannerView = DaroAdBannerView(adUnit: adUnit)
bannerView.adUnit = adUnit
bannerView.delegate = self
bannerView.loadAd()
// DaroAdBannerViewDelegate
func bannerViewDidReceiveAd(_ bannerView: DaroAdBannerView)
func bannerView(_ bannerView: DaroAdBannerView, didFailToReceiveAdWithError error: Error)
// ... other delegate method implementations
Show Previous Code - DaroMAds reward SDK
Show Previous Code - DaroMAds reward SDK
let adUnit = DaroMAdUnit(adUnitID: "your_ad_unit_id", format: .banner)
let bannerAdView = DaroMAdView(adUnit: adUnit)
bannerAdView.delegate = self
bannerAdView.impressionDelegate = self
bannerAdView.clickDelegate = self
bannerAdView.loadAd()
// DaroMAdViewDelegate, DaroMAdImpressionDelegate, DaroMAdClickDelegate
func didLoad(_ ad: DaroMAd)
func didFailToLoadAd(for adUnitIdentifier: String, with error: DaroMError)
// ... other delegate method implementations
let adUnit = DaroAdUnit(unitId: "your_ad_unit_id")
let bannerView = DaroAdBannerView(unit: adUnit, bannerSize: .banner)
bannerView.listener.onAdClicked = { adInfo in
print("[DARO] Listener Sample Banner Ad clicked: \(adInfo)")
}
bannerView.listener.onAdImpression = { adInfo in
print("[DARO] Listener Sample Banner Ad impression: \(adInfo)")
}
bannerView.listener.onAdLoadSuccess = { ad, adInfo in
print("[DARO] Listener Sample Banner Ad loaded: \(ad) \(adInfo)")
}
bannerView.listener.onAdLoadFail = { error in
print("[DARO] Listener Sample Banner Ad failed: \(error)")
}
bannerView.loadAd()
Show Interstitial Ads
Show Interstitial Ads
Show Previous Code - DaroAds non-reward SDK
Show Previous Code - DaroAds non-reward SDK
let adUnit = DaroAdInterstitialUnit(id: "your_ad_unit_id")
DaroInterstitialAd.load(adUnit: adUnit) { result in
switch result {
case .success(let interstitialAd):
interstitialAd.fullScreenDelegate = self
// Show ad
interstitialAd.present(from: viewController)
case .failure(let error):
print("Interstitial ad load failed: \(error)")
}
}
// DaroFullScreenAdDelegate
func didFailToPresent(with error: Error)
func willPresentFullScreenContent()
func didDismissFullScreenContent()
// ... other delegate method implementations
Show Previous Code - DaroMAds reward SDK
Show Previous Code - DaroMAds reward SDK
let adUnit = DaroMAdUnit(adUnitID: "your_ad_unit_id", format: .interstitial)
let interstitialAd = DaroMInterstitialAd(adUnit: adUnit)
interstitialAd.loadingDelegate = self
interstitialAd.displayDelegate = self
interstitialAd.impressionDelegate = self
interstitialAd.clickDelegate = self
interstitialAd.load()
// DaroMAdLoadingDelegate, DaroMAdImpressionDelegate, DaroMAdDisplayDelegate, DaroMAdClickDelegate
func didLoad(_ ad: DaroMAd)
func didFailToLoadAd(for adUnitIdentifier: String, with error: DaroMError)
// ... other delegate method implementations
let adUnit = DaroAdUnit(unitId: "your_ad_unit_id")
let interstitialAdLoader = DaroInterstitialAdLoader(unit: adUnit)
interstitialAdLoader.listener.onAdLoadSuccess = { ad, adInfo in
print("[DARO] Listener Sample Interstitial Ad loaded: \(ad) \(adInfo)")
}
interstitialAdLoader.listener.onAdLoadFail = { error in
print("[DARO] Listener Sample Interstitial Ad failed: \(error)")
}
interstitialAdLoader.listener.onAdClicked = { adInfo in
print("[DARO] Listener Sample Interstitial Ad clicked: \(adInfo)")
}
interstitialAdLoader.listener.onAdImpression = { adInfo in
print("[DARO] Listener Sample Interstitial Ad impression: \(adInfo)")
}
// Load ad
self.daroInterstitialAd = try? await interstitialAdLoader.loadAd()
// Set ad display listeners
self.daroInterstitialAd?.interstitialListener.onShown = { adInfo in
print("[DARO] Listener Sample Interstitial Ad shown: \(adInfo)")
}
self.daroInterstitialAd?.interstitialListener.onDismiss = { adInfo in
print("[DARO] Listener Sample Interstitial Ad dismissed: \(adInfo)")
}
self.daroInterstitialAd?.interstitialListener.onFailedToShow = { adInfo, error in
print("[DARO] Listener Sample Interstitial Ad failed to show: \(adInfo) \(error)")
}
Show Rewarded Ads
Show Rewarded Ads
Show Previous Code - DaroAds non-reward SDK
Show Previous Code - DaroAds non-reward SDK
let adUnit = DaroAdRewardedUnit(id: "your_ad_unit_id")
DaroRewardedAd.load(adUnit: adUnit) { result in
switch result {
case .success(let rewardedAd):
rewardedAd.fullScreenDelegate = self
// Show ad
rewardedAd.present(from: viewController) { rewardItem in
print("Reward earned: \(rewardItem.amount) \(rewardItem.type)")
}
case .failure(let error):
print("Rewarded ad load failed: \(error)")
}
}
// DaroFullScreenAdDelegate
func didFailToPresent(with error: Error)
func willPresentFullScreenContent()
func didDismissFullScreenContent()
// ... other delegate method implementations
Show Previous Code - DaroMAds reward SDK
Show Previous Code - DaroMAds reward SDK
let adUnit = DaroMAdUnit(adUnitID: "your_ad_unit_id", format: .rewarded)
let rewardedAd = DaroMRewardedAd(adUnit: adUnit)
rewardedAd.loadingDelegate = self
rewardedAd.displayDelegate = self
rewardedAd.rewardDelegate = self
rewardedAd.impressionDelegate = self
rewardedAd.clickDelegate = self
rewardedAd.load()
// DaroMRewardedAdDelegate, DaroMAdLoadingDelegate, DaroMAdImpressionDelegate, DaroMAdDisplayDelegate, DaroMAdClickDelegate
func didLoad(_ ad: DaroMAd)
func didFailToLoadAd(for adUnitIdentifier: String, with error: DaroMError)
func didEarnReward(_ reward: DaroMReward)
// ... other delegate method implementations
let adUnit = DaroAdUnit(unitId: "your_ad_unit_id")
let rewardedAdLoader = DaroRewardedAdLoader(unit: adUnit)
rewardedAdLoader.listener.onAdClicked = { adInfo in
print("[DARO] Listener Sample Rewarded Ad clicked: \(adInfo)")
}
rewardedAdLoader.listener.onAdImpression = { adInfo in
print("[DARO] Listener Sample Rewarded Ad impression: \(adInfo)")
}
rewardedAdLoader.listener.onAdLoadSuccess = { ad, adInfo in
print("[DARO] Listener Sample Rewarded Ad loaded: \(ad) \(adInfo)")
}
rewardedAdLoader.listener.onAdLoadFail = { error in
print("[DARO] Listener Sample Rewarded Ad failed: \(error)")
}
self.daroRewardedAd = try? await rewardedAdLoader.loadAd()
self.daroRewardedAd?.rewardedAdListener.onEarnedReward = { adInfo, rewardedItem in
print("[DARO] Listener Sample Reward Ad earned: \(adInfo) \(rewardedItem)")
}
self.daroRewardedAd?.rewardedAdListener.onShown = { adInfo in
print("[DARO] Listener Sample Reward Ad shown: \(adInfo)")
}
self.daroRewardedAd?.rewardedAdListener.onDismiss = { adInfo in
print("[DARO] Listener Sample Reward Ad dismissed: \(adInfo)")
}
self.daroRewardedAd?.rewardedAdListener.onFailedToShow = { adInfo, error in
print("[DARO] Listener Sample Reward Ad failed to show: \(adInfo) \(error)")
}
Show App Open Ads
Show App Open Ads
Show Previous Code - DaroAds non-reward SDK
Show Previous Code - DaroAds non-reward SDK
let adUnit = DaroAdAppOpenUnit(id: "your_ad_unit_id")
DaroAppOpenAd.load(adUnit: adUnit) { result in
switch result {
case .success(let appOpenAd):
appOpenAd.fullScreenDelegate = self
// Show ad
appOpenAd.present(from: viewController)
case .failure(let error):
print("App open ad load failed: \(error)")
}
}
// DaroFullScreenAdDelegate
func didFailToPresent(with error: any Error)
func willPresentFullScreenContent()
func didDismissFullScreenContent()
// ... other delegate method implementations
Show Previous Code - DaroMAds reward SDK
Show Previous Code - DaroMAds reward SDK
let adUnit = DaroMAdUnit(adUnitID: "your_ad_unit_id", format: .appOpen)
let appOpenAd = DaroMAppOpenAd(adUnit: adUnit)
appOpenAd.loadingDelegate = self
appOpenAd.displayDelegate = self
appOpenAd.impressionDelegate = self
appOpenAd.clickDelegate = self
appOpenAd.load()
// DaroMAdLoadingDelegate, DaroMAdImpressionDelegate, DaroMAdDisplayDelegate, DaroMAdClickDelegate
func didLoad(_ ad: DaroMAd)
func didFailToLoadAd(for adUnitIdentifier: String, with error: DaroMError)
// ... other delegate method implementations
let adUnit = DaroAdUnit(unitId: "your_ad_unit_id")
let appOpenAdLoader = DaroAppOpenAdLoader(unit: .appOpenUnit)
appOpenAdLoader.listener.onAdLoadSuccess = { ad, adInfo in
print("[DARO] Listener AppOpenAd loaded: \(ad) \(adInfo)")
}
appOpenAdLoader.listener.onAdLoadFail = { error in
print("[DARO] Listener AppOpenAd failed: \(error)")
}
appOpenAdLoader.listener.onAdClicked = { adInfo in
print("[DARO] Listener AppOpenAd clicked: \(adInfo)")
}
appOpenAdLoader.listener.onAdImpression = { adInfo in
print("[DARO] Listener AppOpenAd impression: \(adInfo)")
}
let appOpenAd = try await appOpenAdLoader.loadAd()
appOpenAd.appOpenAdListener.onShown = { adInfo in
print("[DARO] Listener AppOpenAd shown: \(adInfo)")
}
appOpenAd.appOpenAdListener.onDismiss = { adInfo in
print("[DARO] Listener AppOpenAd dismissed: \(adInfo)")
}
appOpenAd.appOpenAdListener.onFailedToShow = { adInfo, error in
print("[DARO] Listener AppOpenAd failed to show: \(adInfo) \(error)")
}
Show Native Ads
Show Native Ads
Show Previous Code - DaroAds non-reward SDK
Show Previous Code - DaroAds non-reward SDK
// Create custom native view
final class CustomNativeAdView: DaroNativeAdContentView {
private var titleLabel = UILabel()
private var bodyLabel = UILabel()
private var mediaView = DaroMediaView()
private var callToActionButton = UIButton()
required init() {
super.init()
layout()
bindViews(
headlineLabel: titleLabel,
callToActionButton: callToActionButton,
bodyLabel: bodyLabel,
mediaView: mediaView
)
}
// ... layout code
}
// Usage
let adUnit = DaroNativeAdUnit(id: "your_ad_unit_id")
let nativeAdView = DaroNativeAdView(
adUnit: adUnit,
nativeAdContentViewType: CustomNativeAdView.self
)
nativeAdView.delegate = self
nativeAdView.loadAd()
// DaroNativeAdDelegate
func nativeAdDidRecordClick(_ nativeAd: DaroNativeAd) { }
func nativeAdDidRecordImpression(_ nativeAd: DaroNativeAd) { }
Show Previous Code - DaroMAds reward SDK
Show Previous Code - DaroMAds reward SDK
// Create custom native view
final class CustomNativeAdView: DaroMNativeAdContentView {
public override var titleLabel: UILabel? {
get { internalTitleLabel }
set { super.titleLabel = newValue }
}
let internalTitleLabel = UILabel()
public override var iconImageView: UIImageView? {
get { internalIconImageView }
set { super.iconImageView = newValue }
}
let internalIconImageView = UIImageView()
public override var callToActionButton: UIButton? {
get { internalCallToActionButton }
set { super.callToActionButton = newValue }
}
let internalCallToActionButton = UIButton()
required init() {
super.init()
layout()
let binder = DaroMNativeAdViewBinder { builder in
builder.titleLabelTag = 1001
builder.builder.iconImageViewTag = 1004
builder.callToActionButtonTag = 1007
}
bindViews(with: binder)
}
// ... layout code
}
// Usage
let adUnit = DaroMAdUnit(adUnitID: "your_ad_unit_id", format: .native)
let nativeAdView = CustomNativeAdView()
nativeAdView.loadAd()
// Create custom native view
final class CustomNativeAdView: DaroAdNativeView {
private var titleLabel = UILabel()
private var advertiserLabel = UILabel()
private var bodyLabel = UILabel()
private var iconImageView = UIImageView()
private var mediaContentView = UIView()
private var callToActionButton = UIButton()
override init(unit: DaroAdUnit) {
super.init(unit: unit)
layout()
// Bind views
bindViews(
titleLabel: titleLabel,
advertiserLabel: advertiserLabel,
bodyLabel: bodyLabel,
iconImageView: iconImageView,
mediaContentView: mediaContentView,
callToActionButton: callToActionButton
)
}
// ... layout code
}
// Usage
let adUnit = DaroAdUnit(unitId: "your_ad_unit_id")
let nativeAdView = CustomNativeAdView(unit: adUnit)
view.addSubview(nativeAdView)
// Set listeners
nativeAdView.listener.onAdLoadSuccess = { ad, adInfo in
print("[DARO] Native Ad loaded: \(ad) \(adInfo)")
}
nativeAdView.listener.onAdLoadFail = { error in
print("[DARO] Native Ad failed: \(error)")
}
nativeAdView.listener.onAdClicked = { adInfo in
print("[DARO] Native Ad clicked: \(adInfo)")
}
nativeAdView.listener.onAdImpression = { adInfo in
print("[DARO] Native Ad impression: \(adInfo)")
}
nativeAdView.loadAd()
Show Light Popup Ads (New)
Show Light Popup Ads (New)
let adUnit = DaroAdUnit(unitId: "your_ad_unit_id")
// Light popup configuration
let configuration = DaroLightPopupConfiguration()
// Modify desired settings
let lightPopupAdLoader = DaroLightPopupAdLoader(unit: adUnit)
lightPopupAdLoader.listener.onAdClicked = { adInfo in
print("[DARO] Listener Sample LightPopup Ad clicked: \(adInfo)")
}
lightPopupAdLoader.listener.onAdImpression = { adInfo in
print("[DARO] Listener Sample LightPopup Ad impression: \(adInfo)")
}
lightPopupAdLoader.listener.onAdLoadSuccess = { [weak self] ad, adInfo in
print("[DARO] Listener Sample Light Popup Ad loaded: \(ad) \(adInfo)")
self?.daroLightPopupAd = ad
self?.daroLightPopupAd?.lightPopupAdListener.onShown = { adInfo in
print("[DARO] Listener Sample Light Popup Ad shown: \(adInfo)")
}
self?.daroLightPopupAd?.lightPopupAdListener.onDismiss = { adInfo in
print("[DARO] Listener Sample Light Popup Ad dismissed: \(adInfo)")
}
self?.daroLightPopupAd?.lightPopupAdListener.onFailedToShow = { adInfo, error in
print("[DARO] Listener Sample Light Popup Ad failed to show: \(adInfo) \(error)")
}
}
lightPopupAdLoader.listener.onAdLoadFail = { error in
print("[DARO] Listener Sample LightPopup Ad failed: \(error)")
}
lightPopupAdLoader.loadAd()
Migration Checklist
Verify Project Configuration Changes
- Check currently used SDK version (
DaroAdsorDaroMAds) - Organize list of existing ad unit IDs
- Apply configuration file (
daro-service.json->ios-daro-key.txt) - Add DaroAppKey to Info.plist (check App ID in Daro Dashboard)
Code Changes
- Update Podfile
- Modify SDK initialization code
- Modify ad unit creation code
- Change from delegate methods to listener registration
- Apply code changes for each ad format
Test Items
- Confirm SDK initialization success
- Test load/display for each ad type
- Test ad interactions (clicks, impressions)
- Verify listener calls
Troubleshooting
Common Issues
Show SDK Initialization Failure
Show SDK Initialization Failure
<key>DaroAppKey</key>
<string>your_app_key_here</string>
Show Configuration File Error
Show Configuration File Error
Show Ad Load Failure
Show Ad Load Failure

