Skip to content

Commit 3064b3e

Browse files
Mobile Ads Developer Relationscopybara-github
authored andcommitted
Added AdResponseInfo snippet.
PiperOrigin-RevId: 783468996
1 parent 631855c commit 3064b3e

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
using System;
3+
using System.Collections.Generic;
4+
using UnityEngine;
5+
6+
using GoogleMobileAds.Api;
7+
using GoogleMobileAds.Common;
8+
9+
namespace GoogleMobileAds.Snippets
10+
{
11+
/// <summary>
12+
/// Code snippets used for the developer guides.
13+
/// </summary>
14+
internal class AdResponseInfoUtility
15+
{
16+
// [START get_ad_source_name]
17+
private string GetAdSourceName(AdapterResponseInfo loadedAdapterResponseInfo)
18+
{
19+
if (loadedAdapterResponseInfo == null)
20+
{
21+
return string.Empty;
22+
}
23+
24+
string adSourceName = loadedAdapterResponseInfo.AdSourceName;
25+
26+
if (adSourceName == "Custom Event")
27+
{
28+
29+
#if UNITY_ANDROID
30+
if (loadedAdapterResponseInfo.AdapterClassName ==
31+
"com.google.ads.mediation.sample.customevent.SampleCustomEvent")
32+
{
33+
adSourceName = "Sample Ad Network (Custom Event)";
34+
}
35+
#elif UNITY_IPHONE
36+
if (loadedAdapterResponseInfo.AdapterClassName == "SampleCustomEvent")
37+
{
38+
adSourceName = "Sample Ad Network (Custom Event)";
39+
}
40+
#endif
41+
42+
}
43+
return adSourceName;
44+
}
45+
// [END get_ad_source_name]
46+
}
47+
}

0 commit comments

Comments
 (0)