Search...
Menu

Rewarded Video Ads

πŸ’‘Tips

  • Automatically manages multi-placement parallel loading, caching, and price-comparison display, developer only needs SmartLoad β†’ SmartIsReady β†’ SmartShow
  • Must ensure McSdk.InitializeSdk() is completed before calling SmartLoadRewardedAd(), otherwise the call will be ignored
  • SDK automatically refills after ad is closed, no need to manually reload
  • OnDidRewardUserForAd is the only reliable time to grant rewards, make sure to handle reward logic in this callback
  • Smart Cache has an independent callback channel McSdkCallbacks.SmartCache.Rewarded, completely isolated from the standard ad placement callback McSdkCallbacks.Rewarded

csharp Copy
public void InitializeSmartRewardedAd()
{
    // Smart Cache independent callback channel (completely isolated from Ad Placement Mode)
    McSdkCallbacks.SmartCache.Rewarded.OnDidLoadAd += OnSmartRewardedAdLoaded;
    McSdkCallbacks.SmartCache.Rewarded.OnDidFailToLoadAd += OnSmartRewardedAdLoadFailed;
    McSdkCallbacks.SmartCache.Rewarded.OnDidDisplayAd += OnSmartRewardedAdDisplayed;
    McSdkCallbacks.SmartCache.Rewarded.OnDidHideAd += OnSmartRewardedAdHidden;
    McSdkCallbacks.SmartCache.Rewarded.OnDidClickAd += OnSmartRewardedAdClicked;
    McSdkCallbacks.SmartCache.Rewarded.OnDidFailToDisplayAd += OnSmartRewardedAdDisplayFailed;
    McSdkCallbacks.SmartCache.Rewarded.OnDidPayRevenueForAd += OnSmartRewardedAdRevenuePaid;
    McSdkCallbacks.SmartCache.Rewarded.OnDidAdLoadFinished += OnSmartRewardedAdLoadFinished;
    // Rewarded video specific callbacks
    McSdkCallbacks.SmartCache.Rewarded.OnDidRewardUserForAd += OnSmartRewardedAdUserRewarded;
    McSdkCallbacks.SmartCache.Rewarded.OnDidAdVideoStarted += OnSmartRewardedAdVideoStarted;
    McSdkCallbacks.SmartCache.Rewarded.OnDidAdVideoCompleted += OnSmartRewardedAdVideoCompleted;

    // No need to pass adUnitId, managed by server strategy
    McSdk.SmartLoadRewardedAd();
}

private void OnSmartRewardedAdLoaded(string adUnitId, McSdkBase.AdInfo adInfo)
{
    // At least one ad is ready
}

private void OnSmartRewardedAdLoadFailed(McSdkBase.ErrorInfo errorInfo)
{
    // All ad placements failed to load
    // Automatically retries, no manual reload needed
}

private void OnSmartRewardedAdDisplayed(string adUnitId, McSdkBase.AdInfo adInfo)
{
    // Display success callback
}

private void OnSmartRewardedAdHidden(string adUnitId, McSdkBase.AdInfo adInfo)
{
    // Ad closed callback
    // SDK automatically refills, no manual operation needed
}

private void OnSmartRewardedAdClicked(string adUnitId, McSdkBase.AdInfo adInfo)
{
    // Click callback
}

private void OnSmartRewardedAdDisplayFailed(McSdkBase.ErrorInfo errorInfo, McSdkBase.AdInfo adInfo)
{
    // Display failed callback
    // Automatically handled, no manual reload needed
}

private void OnSmartRewardedAdRevenuePaid(string adUnitId, McSdkBase.AdInfo adInfo)
{
    // Revenue callback
}

private void OnSmartRewardedAdLoadFinished()
{
    // End of all ad placements load round callback (triggers regardless of success or failure)
    // Differences from OnDidLoadAd / OnDidFailToLoadAd:
    // OnDidLoadAd β€” triggers when at least one ad placement loads successfully
    // OnDidFailToLoadAd β€” triggers when all ad placements fail to load
    // OnDidAdLoadFinished β€” always triggers when the current load round finishes
}

private void OnSmartRewardedAdUserRewarded(string adUnitId, McSdkBase.Reward reward, McSdkBase.AdInfo adInfo)
{
    // Rewarded video specific: user completed reward, grant reward
    // ⚠️ This is the only reliable time to grant rewards
    Debug.Log("Reward type: " + reward.Label + " x " + reward.Amount);
}

private void OnSmartRewardedAdVideoStarted(string adUnitId, McSdkBase.AdInfo adInfo)
{
    // Rewarded video specific: video playback started
}

private void OnSmartRewardedAdVideoCompleted(string adUnitId, McSdkBase.AdInfo adInfo)
{
    // Rewarded video specific: video playback completed
}

⚠️ Note: In Smart Cache mode, there is no need to manually call SmartLoadRewardedAd() in the OnDidFailToLoadAd / OnDidFailToDisplayAd / OnDidHideAd callbacks to reload. The SDK automatically manages refill and retry internally.

πŸ“Œ Duplicate calls to SmartLoadRewardedAd() during loading will be automatically ignored, developers do not need to manually handle anti-duplicate logic.

πŸ“Œ Smart Cache callback McSdkCallbacks.SmartCache.Rewarded is completely isolated from the standard ad placement callback McSdkCallbacks.Rewarded. Both callback sets can be registered simultaneously without interference.


csharp Copy
if (McSdk.SmartIsRewardedAdReady()) {
    // SDK automatically selects the ad with the highest eCPM from the cache pool to show
    McSdk.SmartShowRewardedAd();
}

πŸ“Œ When SmartIsRewardedAdReady() returns false, the SDK automatically triggers background refill, developers do not need to perform additional operations.

πŸ“Œ After the ad is shown, the SDK automatically refills, maintaining available ads in the cache pool.


3. Set Custom Parameters

csharp Copy
McSdk.SmartSetRewardedAdExtraParameter("key", "value");
#if UNITY_ANDROID
    McSdk.SmartSetRewardedAdLocalExtraParameter("key", new AndroidJavaObject("java.lang.String", "value"));
#elif UNITY_IOS
    McSdk.SmartSetRewardedAdLocalExtraParameter("key", "value");
#endif

// Must be set before SmartLoadRewardedAd(), parameters take effect for all subsequent load requests
McSdk.SmartLoadRewardedAd();

Last modified: 2026-04-03Powered by