Unity plugin for AdDeals

This is a cross-platform Unity plugin for AdDeals's SDKs. It combines and supports three platforms together: Windows(UWP), iOS, and Android.

System requirements:

Integrate

AdDeals.AdDealsWrapper.Init("AppID", "AppKey");

int adType = AdDealsWrapper.AdTypeInterstitial; // 1:interstitial 2: reward video
AdDeals.AdDealsWrapper.ShowAd(adType);

Windows UWP build

iOS build

    strip_invalid_archs() {
        binary="$1"
        # Get architectures for current target binary
        binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)"
        # Intersect them with the architectures we are building for
        intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)"
        # If there are no archs supported by this binary then warn the user
        if [[ -z "$intersected_archs" ]]; then
            echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)."
            STRIP_BINARY_RETVAL=0
            return
        fi
        stripped=""
        for arch in $binary_archs; do
            if ! [[ "${ARCHS}" == *"$arch"* ]]; then
                # Strip non-valid architectures in-place
                lipo -remove "$arch" -output "$binary" "$binary" || exit 1
                stripped="$stripped $arch"
            fi
        done
        if [[ "$stripped" ]]; then
            echo "Stripped $binary of architectures:$stripped"
        fi
        STRIP_BINARY_RETVAL=1
    }

    binary="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AdDeals.framework/AdDeals"
    # Strip invalid architectures so "fat" simulator / device frameworks work on device
    if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then
        strip_invalid_archs "$binary"
    fi

and the script phase should be look like follow

Unity iOS script phase

Android build

    ...
    android {
        ...
        defaultConfig {
            minSdkVersion 15
            targetSdkVersion 28
            versionCode 1
            versionName '0.1'
            ...
        }
        ...
    }
    ...

API

Methods

void AdDeals.AdDealsWrapper.Init(String appID, String appKey);
void AdDeals.AdDealsWrapper.SetConsent(int consent);
void AdDeals.AdDealsWrapper.IsAvailable(int adType, int uiOrientation);
void AdDeals.AdDealsWrapper.CacheAd(int adType, string placementID, int uiOrientation);
void AdDeals.AdDealsWrapper.ShowAd(int adType, string placementID, int uiOrientation);

Note: placementID is an advanced feature and in most cases you can just leave it "". In case you want to use placementIDs you should contact addeals@ahead-solutions.com

Callback

SDK trigers feedback events (callbacks) notifying the client app when action are performed (either by SDK or end user; typically when there is an ad being shown/clicked/closed) or when failures occur. Following is the exhaustive listing of exposed callbacks :

public static event AdAvailableHandler AdAvailableEvent;
public static event AdEventHandler SDKNotInitializedEvent;
public static event AdEventHandler ShowAdVideoRewardGrantedEvent;
public static event AdEventHandler ShowAdSucessEvent;
public static event AdEventStringHandler ShowAdFailedEvent;
public static event AdEventHandler CacheAdSuccessEvent;
public static event AdEventStringHandler CacheAdFailedEvent;
public static event AdEventHandler MinDelayBtwAdsNotReachedEvent;
public static event AdEventHandler AdClosedTap;
public static event AdEventHandler AdClickedTap;
public static event AdEventHandler AdManagerInitSDKSuccess;
public static event AdEventStringHandler AdManagerInitSDKFailed;
public static event AdEventHandler AdManagerConsentSuccess;
public static event AdEventStringHandler AdManagerConsentFailed;
public static event AdEventHandler AdManagerAppDownloadSourceDetected;
public static event AdEventHandler AdManagerAppSessionSourceDetected;

here is a sample to subscribe SDK init success:

void AdManagerInitSDKSuccess() {
    //addeals init success
}
AdDeals.AdDealsWrapper.AdManagerInitSDKSuccess += AdManagerInitSDKSuccess;

Constants

UI Orientation

AdDealsWrapper.UIOrientationUnset;
AdDealsWrapper.UIOrientationPortrait;
AdDealsWrapper.UIOrientationLandscape;

Ad type

AdDealsWrapper.AdTypeInterstitial;
AdDealsWrapper.AdTypeRewardedVideo;
public const int UserConsentNotApplicable;
public const int UserConsentRevoke;
public const int UserConsentGrant;

Verification

Tested on the follow Unity versions:

Sample Project

https://github.com/sdkbox/AdDeals-Unity-Sample

Issues