-
Notifications
You must be signed in to change notification settings - Fork 12
Advertising
VirtueSky edited this page Dec 3, 2024
·
14 revisions
(Tested with applovin > v5.11.3 and google admob > v8.5.2)
- Create AdClient and AdVariable
- Choose AdNetwork Max or Admob
- You can click install sdk if your project doesn't have it yet.
- Add Scripting Define Symbols to use
(For Admob, you can get the test Id by going to Context Menu
and selecting Get Id Test
)
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using VirtueSky.Ads;
public class AdsManager : MonoBehaviour
{
public TextMeshProUGUI textNoti;
public AdUnitVariable banner;
public AdUnitVariable inter;
public AdUnitVariable reward;
public void ShowBanner()
{
Debug.Log(banner.IsReady());
banner.Show();
}
public void ShowInter()
{
if (inter.IsReady())
{
LogMessage("inter is ready");
inter.Show().OnCompleted(() => { LogMessage("inter is completed"); });
}
else
{
LogMessage("Inter is not ready");
}
}
public void ShowReward()
{
if (reward.IsReady())
{
LogMessage("reward is ready");
reward.Show().OnCompleted(() => { LogMessage("Reward is completed"); }).OnSkipped(() => { LogMessage("reward is skipped"); });
}
else
{
LogMessage("reward is not ready");
}
}
void LogMessage(string message)
{
textNoti.text = message;
Debug.Log(message);
}
}
- Android: Advertising will only be initialized after user consent allows requesting ads.
- iOS: If ATT is authorized, GDPR compliance will be initialized, and advertising will only be initialized after user consent allows requesting ads.
If ATT is not authorized, GDPR compliance will not be initialized, and advertising will proceed without GDPR conditions. - When using GDPR, make sure you have created the GDPR message in Admob
- Advertising is successfully initialized only when the Android logcat shows
currentAdClient: ...