Unity Managed MAX
OriviaMaxSdk is a high-level static wrapper over AppLovin MAX that manages the full ad lifecycle — loading, retry on failure — so you don't have to wire MAX callbacks yourself.
Import Package
Make sure the Orivia SDK namespace is available in your scripts:
using Orivia.Monetization;
Setup
1. Define SDK Keys & Ad Unit IDs
Declare your MAX SDK key, Orivia publisher ID, and ad unit IDs:
private const string MaxSdkKey = "YOUR_MAX_SDK_KEY";
private const string OriviaPublisherId = "YOUR_ORIVIA_PUBLISHER_ID";
#if UNITY_IOS
private const string InterstitialAdUnitId = "IOS_INTERSTITIAL_ID";
private const string RewardedAdUnitId = "IOS_REWARDED_ID";
#else
private const string InterstitialAdUnitId = "ANDROID_INTERSTITIAL_ID";
private const string RewardedAdUnitId = "ANDROID_REWARDED_ID";
#endif
2. Initialize
Subscribe to callbacks, set the MAX SDK key, then call Init:
void Start()
{
// For debug purposes only.
OriviaMaxSdk.SetLoggingEnabled(true);
OriviaMaxSdk.OnInterstitialLoaded += OnInterstitialLoaded;
OriviaMaxSdk.OnRewardedLoaded += OnRewardedLoaded;
MaxSdk.SetSdkKey(MaxSdkKey);
OriviaMaxSdk.Init(
publisherId: OriviaPublisherId,
defaultInterstitialAdUnitId: InterstitialAdUnitId,
defaultRewardedAdUnitId: RewardedAdUnitId,
initListener: new InitListener()
);
}
Init initializes Orivia SDK first, fetches remote config, then initializes AppLovin MAX. Both must complete before ads can be loaded.
Init also accepts a defaultBannerAdUnitId. OriviaMaxSdk does not load or show banners itself — manage banners directly via MaxSdk — but passing it in lets the ad unit rotation logic account for banner placements too.
Important
You may subscribe to AppLovin MAX callbacks directly for informational purposes (e.g., analytics), but all ad display operations must go through OriviaMaxSdk.
3. Implement IInitListener
private class InitListener : OriviaMaxSdk.IInitListener
{
public void OnInitFinished()
{
// Both Orivia SDK and MAX are ready — safe to start loading
OriviaMaxSdk.LoadInterstitial();
OriviaMaxSdk.LoadRewarded();
}
}
Info
OnInitFinished is called after both Orivia SDK config and AppLovin MAX have initialized successfully. It is the recommended place to trigger the first ad load.
Loading Ads
OriviaMaxSdk.LoadInterstitial();
OriviaMaxSdk.LoadRewarded();
Behavior:
- If an ad is already ready — fires
OnInterstitialLoaded/OnRewardedLoadedimmediately and returns. - If a load is already in progress — skips silently.
After a failed load, OriviaMaxSdk retries automatically. You do not need to schedule retries yourself.
Callbacks
Subscribe before calling Init to avoid missing the first event:
OriviaMaxSdk.OnInterstitialLoaded += () =>
{
// Ad is ready to show. IsInterstitialReady == true.
};
OriviaMaxSdk.OnRewardedLoaded += () =>
{
// Ad is ready to show. IsRewardedReady == true.
};
The callback fires only when the full load cycle is complete. It is safe to call ShowInterstitial / ShowRewarded directly from the callback.
OnInterstitialHidden / OnRewardedHidden fire once the shown ad is gone, so you can safely request the next ad:
OriviaMaxSdk.OnInterstitialHidden += (adUnitId, adInfo) =>
{
// Interstitial is done — safe to call LoadInterstitial again.
};
OriviaMaxSdk.OnRewardedHidden += (adUnitId, adInfo) =>
{
// Rewarded is done — safe to call LoadRewarded again.
};
Info
OnInterstitialHidden / OnRewardedHidden are not a 1:1 passthrough of AppLovin MAX's own hidden callback. OriviaMaxSdk starts a guard as soon as ShowInterstitial / ShowRewarded is called; if AppLovin MAX never confirms the ad was dismissed, this event fires on its own after a server-configured delay. Treat it as "this ad is done" rather than a precise timestamp of when it actually closed.
Extra Value
Subscribe to changes of a single server-configured extra value for an ad type — the callback fires immediately with the current value, then again on every subsequent change:
IDisposable subscription = OriviaMaxSdk.SubscribeOnExtraValue(AdType.Interstitial, "my_key", value =>
{
Debug.Log($"my_key updated: {value}");
});
// Later, when no longer needed:
subscription.Dispose();
Info
For a one-off read without subscribing, use OriviaSdk.GetExtraValue(adType, key) directly.
Showing Ads
placement and customData are passed directly to AppLovin MAX and behave identically to MaxSdk.ShowInterstitial / MaxSdk.ShowRewardedAd.
OriviaMaxSdk.ShowInterstitial(); // no placement
OriviaMaxSdk.ShowInterstitial("game_over"); // with placement
OriviaMaxSdk.ShowInterstitial("level_end", "my_data"); // with placement + custom data
OriviaMaxSdk.ShowRewarded();
OriviaMaxSdk.ShowRewarded("extra_life");
OriviaMaxSdk.ShowRewarded("extra_life", "my_data"); // with placement + custom data
Important
Show logs a warning and returns early if no ad is ready. Always check IsInterstitialReady / IsRewardedReady before showing, or load first and show from the OnLoaded callback.
Checking Readiness
if (OriviaMaxSdk.IsInterstitialReady)
OriviaMaxSdk.ShowInterstitial("placement");
if (OriviaMaxSdk.IsRewardedReady)
OriviaMaxSdk.ShowRewarded("placement");
Data Collection Only Mode
In this mode OriviaMaxSdk only tracks events — it does not initialize AppLovin MAX, manage ad units, or control loading and display. The publisher drives everything via MaxSdk directly.
Pass dataCollectionOnly: true to Init:
MaxSdk.SetSdkKey(MaxSdkKey);
MaxSdk.InitializeSdk(); // publisher initializes MAX
OriviaMaxSdk.Init(
publisherId: OriviaPublisherId,
defaultInterstitialAdUnitId: InterstitialAdUnitId,
defaultRewardedAdUnitId: RewardedAdUnitId,
dataCollectionOnly: true,
initListener: new InitListener()
);
OnInitFinished fires as soon as the Orivia SDK config is ready — MAX initialization is not awaited.
The publisher loads and shows ads as usual:
MaxSdk.LoadInterstitial(InterstitialAdUnitId);
MaxSdk.ShowInterstitial(InterstitialAdUnitId);
MaxSdk.LoadRewardedAd(RewardedAdUnitId);
MaxSdk.ShowRewardedAd(RewardedAdUnitId);
OriviaMaxSdk.LoadInterstitial, ShowInterstitial, LoadRewarded, and ShowRewarded are disabled in this mode and log a warning if called.
Client Parameters
To pass client parameters to the server:
var nested = new ValueMap.Builder().Put("nested", "value").Build();
var clientParams = new ValueMap.Builder()
.Put("str", "value")
.Put("int", UnityEngine.Random.Range(1, 1000))
.Put("float", 3.43)
.Put("bool", true)
.Put("nested", nested)
.Build();
OriviaSdk.SetClientParams(clientParams);
If the parameters should be passed in the init request, call SetClientParams before OriviaMaxSdk.Init.
Important
Passing null to this method has no effect. To clear the parameters, pass an empty ValueMap.
Logging
Turn on internal logs for debugging:
OriviaMaxSdk.SetLoggingEnabled(true);
Logs appear in logcat (Android) or Xcode Console (iOS).
Privacy
To pass GDPR Applies there are 2 options.
Pass it through CMP IABTCF_gdprApplies property or using SDK method:
OriviaSdk.SetGdprApplies(boolean?)
To pass COPPA:
OriviaSdk.SetCoppa(boolean?)
Null values reset properties.
Full Example
using Orivia.Monetization;
using UnityEngine;
public class AdsManager : MonoBehaviour
{
void Start()
{
// For debug purposes only.
OriviaMaxSdk.SetLoggingEnabled(true);
OriviaMaxSdk.OnInterstitialLoaded += OnInterstitialLoaded;
OriviaMaxSdk.OnRewardedLoaded += OnRewardedLoaded;
MaxSdk.SetSdkKey("YOUR_MAX_SDK_KEY");
OriviaMaxSdk.Init(
publisherId: "YOUR_PUBLISHER_ID",
defaultInterstitialAdUnitId: "YOUR_INTERSTITIAL_AD_UNIT_ID",
defaultRewardedAdUnitId: "YOUR_REWARDED_AD_UNIT_ID",
initListener: new InitListener()
);
}
private void OnInterstitialLoaded()
{
// Ad is ready — show it when appropriate
}
private void OnRewardedLoaded()
{
// Ad is ready — show it when appropriate
}
public void ShowInterstitial()
{
if (OriviaMaxSdk.IsInterstitialReady)
OriviaMaxSdk.ShowInterstitial("my_placement");
}
public void ShowRewarded()
{
if (OriviaMaxSdk.IsRewardedReady)
OriviaMaxSdk.ShowRewarded("my_placement");
}
private class InitListener : OriviaMaxSdk.IInitListener
{
public void OnInitFinished()
{
OriviaMaxSdk.LoadInterstitial();
OriviaMaxSdk.LoadRewarded();
}
}
}