Documentation: https://dev.appsflyer.com/hc/docs/getting-started

iMote PR: https://github.com/leadtechcorp/imote/pull/41/files?diff=split&w=0

Code Changes (iOS) - Ref: iMote

iMote/iMote/AppDelegate/AppDelegate+Adjust.swift

/// logAjustEventForPurchase
/// - Parameters:
///   - price: Double
///   - currency: String
func logAjustEventForPurchase(price: Double, currency: String?) {
    let event = ADJEvent(eventToken: Constants.adjustEventToken)
    event?.setRevenue(price, currency: currency ?? "USD")
    Adjust.trackEvent(event)
}

iMote/iMote/AppDelegate/AppDelegate+Appsflyer.swift → Setup configuration for AppsFlyer

//
//  AppDelegate+Appsflyer.swift
//  iMote
//
//  Created by Sergio Durban on 3/2/25.
//
import AppsFlyerLib
import RevenueCat
import CryptoKit

extension AppDelegate {

    /// This Function use for initialization for appsflyer SDK
    func setupAppsflyer() {
        AppsFlyerLib.shared().appsFlyerDevKey = Constants.appsFlyerToken
        AppsFlyerLib.shared().appleAppID = Constants.AppInfo.applicationID
        AppsFlyerLib.shared().customerUserID = Purchases.shared.appUserID
        AppsFlyerLib.shared().appInviteOneLinkID = Constants.appInviteOneLinkID
        AppsFlyerLib.shared().delegate = self
#if DEBUG
        AppsFlyerLib.shared().isDebug = true
#endif
        AppsFlyerLib.shared().start()

        setAppsflyerId()
        setFBPartnerData()
        Purchases.shared.attribution.collectDeviceIdentifiers()
    }

    /// setAppsflyerId
    private func setAppsflyerId() {
        Purchases.shared.attribution.collectDeviceIdentifiers()
        Purchases.shared.attribution.setAppsflyerID(AppsFlyerLib.shared().getAppsFlyerUID())
    }

    /// setFBPartnerData
    private func setFBPartnerData() {

        let cryptoManager = CryptoManager()
        let rcIdSha256 = cryptoManager.sha256(text: Purchases.shared.appUserID)

        let metaData = [
            Constants.externalID: rcIdSha256
        ]

        AppsFlyerLib.shared().setPartnerData(partnerId: Constants.facebookInt, partnerInfo: metaData)
        AppsFlyerLib.shared().setPartnerData(partnerId: Constants.metawebInt, partnerInfo: metaData)
    }

    /// logAppsFlyerEventForPurchase
    /// - Parameters:
    ///   - price: Double
    ///   - currency: String
    func logAppsFlyerEventForPurchase(price: Double, currency: String?) {
        AppsFlyerLib.shared().logEvent(name: EventsManager.IMoteEvents.purchaseInapp.rawValue, values: [
            AFEventParamPrice: price,
            AFEventParamCurrency: currency ?? "USD"
        ])
    }
}

extension AppDelegate: AppsFlyerLibDelegate {

    /// onConversionDataFail
    /// - Parameter error: Error
    func onConversionDataFail(_ error: any Error) { }

    /// onConversionDataSuccess
    /// - Parameter conversionInfo: [AnyHashable : Any]
    func onConversionDataSuccess(_ conversionInfo: [AnyHashable : Any]) {
        if let status = conversionInfo[Constants.afStatus] as? String {
            if (status == Constants.nonOrganic) {
                // Business logic for Non-organic install scenario is invoked
                if let mediaSource = conversionInfo[Constants.mediaSource] as? String {
                    Purchases.shared.attribution.setMediaSource(mediaSource)
                }
                if let campaign = conversionInfo[Constants.campaign] as? String {
                    Purchases.shared.attribution.setCampaign(campaign)
                }
                if let adGroup = conversionInfo[Constants.adgroup] as? String {
                    Purchases.shared.attribution.setAdGroup(adGroup)
                }
                if let adGroupId = conversionInfo[Constants.adgroupId] as? String {
                    Purchases.shared.attribution.setAdGroup(adGroupId)
                }
            }
        }
    }
}

iMote/iMote/Helper Class/Amplitude Event manager/EventsManager.swift → Added New event here, we are tracking this event when purchase get completed from customer

/// adjustNAppsFlyerEventForPayment is used for log event on Adjust and AppsFlyer for payment success
/// - Parameters:
///   - price: Double type
///   - currency: String optional type
func adjustNAppsFlyerEventForPayment(price: Double, currency: String?) {
    DispatchQueue.main.asyncAfter(deadline: .now() + 10.0) {
        appDelegate.logAjustEventForPurchase(price: price, currency: currency)

        appDelegate.logAppsFlyerEventForPurchase(price: price, currency: currency)
    }
}

iMote/iMote/Module/InAppPurchase/ViewController/InAppPurchaseVC.swift

iMote/iMote/Module/PaymentPlansScreenMojo/ViewController/InAppMojoPurchasePlansVC.swift

iMote/iMote/Module/OnBordingInApp/ViewController/OnBordingInAppVC.swift

iMote/iMote/Module/PaymentScreenFreeTrial/ViewController/PaymentScreenFreeTrialEnableVC.swift

iMote/iMote/Module/PaymentScreenMojo/ViewController/InAppMojoPurchaseVC.swift

→ Calling the event after purchase from common class

EventsManager.shared.adjustNAppsFlyerEventForPayment(price: price, currency: package.storeProduct.currencyCode)

iMote/iMote/Module/Settings/ViewController/SettingsVC.swift → Invitation link to share the app to others

AppLoader.shared.showLoader(viewController: self, type: .animatedGIF)
AppsFlyerShareInviteHelper.generateInviteUrl { generator in
    generator.setReferrerCustomerId(Purchases.shared.appUserID)
    generator.setCampaign("Share Invite")

    return generator
} completionHandler: { url in
    if let url = url {
        let itemsToShare = [textToShare, url] as [Any]

        AppLoader.shared.hideLoader()

        DispatchQueue.main.async { [weak self] in
            self?.showShareDialog(itemsToShare: itemsToShare)
        }
    } else {
        AppLoader.shared.hideLoader()
    }
}

iMote/iMote/Module/Splash/ViewController/SplashVC.swift → Initializing the appsFlyer

appDelegate.setupAppsflyer()