CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.

ALMHelper 2.0.1

ALMHelper 2.0.1

Maintained by MiTu.



 
Depends on:
MiTuKit>= 0
AppLovinSDK>= 0
SkeletonView>= 0
GoogleUserMessagingPlatform>= 0
 

ALMHelper 2.0.1

  • By
  • Mitu Ultra

ALMHelper

Version License Platform

About

HI,
ALMHelper is a powerful Swift library designed to simplify Applovin MAX ad management. It provides:

✅ Easy Ad Loading & Displaying – Load and show Interstitial, Rewarded, Banner, Native, and Open Ads with minimal setup.
✅ Smart Delegation System – Improved delegate handling for cleaner and more maintainable code.
✅ Ad Frequency Control – Avoid ad spam with built-in frequency capping and impression percentage logic.
✅ GDPR & Privacy Compliance – Includes built-in tracking request and CMP handling.
⚡ ALMHelper – The ultimate tool for maximizing your Applovin MAX ad revenue! 🚀

Installation with CocoaPods

To integrate ALMHelper into your Xcode project using CocoaPods, specify it in your Podfile

target 'MyApp' do
  pod 'ALMHelper'
end

Swift Package Manager

Once you have your Swift package set up, adding ALMHelper as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/hominhtuong/ALMHelper.git", .upToNextMajor(from: "1.0.3"))
]

Example code:

The code would look like this:
import ALMHelper

class SplashViewController: UIViewController {
    func setupAd() {
        Task {
            let adUnits = ALAdUnits(
                openAdUnitId: AdUnits.openAdUnitId,
                bannerAdUnitId: AdUnits.bannerAdUnitId,
                interstitialAdUnitId: AdUnits.interstitialAdUnitId,
                rewardAdUnitId: AdUnits.rewardAdUnitId,
                nativeAdUnitId: AdUnits.nativeAdUnitId
            )
            await ALMHelper.shared.setup(sdkKey: applovinSDKKey, units: adUnits)
            
            //Load configs online then setup
            ALMHelper.shared.configs.enableAds = true
            ALMHelper.shared.configs.showInterstitial = true
            //...
            
            ALMHelper.shared.loadInterstitial()
            //...
        }
    }
}
    
Show Ads:
import ALMHelper

class ViewController: UIViewController {
    func nextScreen() {
        
        ALMHelper.shared.showInterstitial()
        self.navigationController?.pushViewController(NextScreen(), animated: true)
    }
    
    func showAdThenNextScreen() {
        ALMHelper.shared.showInterstitial { state in
            if state == .showed { return } 
            self.navigationController?.pushViewController(NextScreen(), animated: true)
        }
    }
    
    func showAdAndNextScreen() {
        ALMHelper.shared.showInterstitial { state in
            if state == .hidden { return } 
            self.navigationController?.pushViewController(NextScreen(), animated: false)
        }
    }
}
🔥 Important!!!!

The state from the completion handler in a successful case will be called twice
didDisplay and didHide (.showed and .hidden).

You can navigate to another screen when state == .showed while the interstitial is being presented (without affecting the user experience) or after it is dismissed with state == .hidden.

Banner Ads:
import ALMHelper

class ViewController: UIViewController {
    func setupView() {
        let bannerView = UIView()
        bannerView >>> view >>> {
            $0.snp.makeConstraints {
                $0.leading.trailing.equalToSuperview()
                $0.bottom.equalTo(botSafe)
                $0.height.equalTo(50)
            }
            $0.attachBanner()
        }
    }
}
Ad Delegate:
extension ViewController: ALMHelperDelegate {
    func didLoad(_ ad: MAAd) {
        printDebug("ad: \(ad.adUnitIdentifier) didload")
    }
    
    func didFailToLoadAd(forAdUnitIdentifier adUnitIdentifier: String, withError error: MAError) {
        printDebug("ad: \(adUnitIdentifier) didFailToLoadAd, withError: \(error.description)")
    }
    
    func didPayRevenue(for ad: MAAd) {
        printDebug("ad: \(ad.adUnitIdentifier) didPayRevenue")
    }
    
    func interstitialAdShowCalled(for adUnitIdentifier: String, placement: String) {
        printDebug("Add tracking: \(adUnitIdentifier) show called at \(placement)")
    }
    
    func showInterstitialAdSuccess(_ ad: MAAd, placement: String) {
        printDebug("Add tracking: \(ad.adUnitIdentifier) show success at \(placement)")
    }
    
    func showInterstitialAdClick(_ ad: MAAd, placement: String) {
        printDebug("Add tracking: \(ad.adUnitIdentifier) show click at \(placement)")
    }
}
Ad Callback display state:
enum AdDisplayState {
    case notReady
    case failed
    case showed
    case hidden
    case didReward(_ amount: Int)

License

ALMHelper is released under the MIT license. See LICENSE for more details.

My website: Visit