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: rewarded video
AdDeals.AdDealsWrapper.ShowAd(adType);

Windows UWP build

Optional: compatible with Microsoft Ads using Windows Store Native

If you need to integrate Microsoft Ads using Windows Store Native plugin, please follow these steps after completed everything above:


...
namespace AdDeals
{
    ...
    public sealed partial class MainPage : Page
    {
    ...
    public MainPage()
    {

        ...
        BridgeBootstrapper.SetUWPBridge(new UWPBridge());

        UnityRT.App.Start(GetSwapChainPanel()); // invoke UnityRT project
    }
    ...
    }
...
}


void App::Start(Windows::UI::Xaml::Controls::SwapChainPanel^ panel)
{
        // AppInit
        InterstitialAdManager::Initialise();
    BannerAdManager::Initialise(panel);
}

iOS build

Unity iOS new script phase

2. add follow script
    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.IsCachedAdAvailable(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 ShowAdVideoRewardedGrantedEvent;
public static event AdEventHandler ShowAdSuccessEvent;
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

Unity Knowledge Point

When you export UWP project form unity, you wll see Develop build in the right corner of the screen. You can hide it by changing the build setting to "Master" on Visual studio.

https://forum.unity.com/threads/unity-uwp-development-build-stamp.450192/