|
| 1 | +// Copyright 2026 Google LLC |
| 2 | + |
| 3 | +using System.Collections.Generic; |
| 4 | +using GoogleMobileAds.Api; |
| 5 | +using GoogleMobileAds.Api.AdManager; |
| 6 | +using UnityEngine; |
| 7 | + |
| 8 | +namespace GoogleMobileAds.Snippets |
| 9 | +{ |
| 10 | + /// <summary> |
| 11 | + /// Code snippets used for the developer guides. |
| 12 | + /// </summary> |
| 13 | + internal class AdRequestSnippets |
| 14 | + { |
| 15 | + private void AddNetworkExtras() |
| 16 | + { |
| 17 | + // [START add_network_extras] |
| 18 | + var adRequest = new AdRequest(); |
| 19 | + adRequest.Extras.Add("collapsible", "bottom"); |
| 20 | + // [END add_network_extras] |
| 21 | + } |
| 22 | + |
| 23 | + private void AddCustomTargeting() |
| 24 | + { |
| 25 | + // [START add_custom_targeting] |
| 26 | + // Example: Pass custom targeting "age=25". |
| 27 | + AdManagerAdRequest newRequest = new AdManagerAdRequest |
| 28 | + { |
| 29 | + CustomTargeting = new Dictionary<string, string> |
| 30 | + { |
| 31 | + { "age", "25" } |
| 32 | + } |
| 33 | + }; |
| 34 | + // [END add_custom_targeting] |
| 35 | + } |
| 36 | + |
| 37 | + private void AddCustomTargetingAsList() |
| 38 | + { |
| 39 | + // [START add_custom_targeting_as_list] |
| 40 | + AdManagerAdRequest newRequest = new AdManagerAdRequest |
| 41 | + { |
| 42 | + CustomTargeting = new Dictionary<string, string> |
| 43 | + { |
| 44 | + { "age", "24, 25, 26" } |
| 45 | + } |
| 46 | + }; |
| 47 | + // [END add_custom_targeting_as_list] |
| 48 | + } |
| 49 | + |
| 50 | + private void AddCategoryExclusions() |
| 51 | + { |
| 52 | + // [START add_category_exclusions] |
| 53 | + AdManagerAdRequest newRequest = new AdManagerAdRequest |
| 54 | + { |
| 55 | + CategoryExclusions = new HashSet<string> |
| 56 | + { |
| 57 | + "automobile", |
| 58 | + "boat" |
| 59 | + } |
| 60 | + }; |
| 61 | + // [END add_category_exclusions] |
| 62 | + } |
| 63 | + |
| 64 | + private void SetPublisherProvidedId() |
| 65 | + { |
| 66 | + // [START set_publisher_provided_id] |
| 67 | + AdManagerAdRequest newRequest = new AdManagerAdRequest |
| 68 | + { |
| 69 | + PublisherProvidedId = "AB123456789" |
| 70 | + }; |
| 71 | + // [END set_publisher_provided_id] |
| 72 | + } |
| 73 | + |
| 74 | + private void SetPublisherProvidedSignals() |
| 75 | + { |
| 76 | + // [START set_publisher_provided_signals] |
| 77 | + AdManagerAdRequest newRequest = new AdManagerAdRequest |
| 78 | + { |
| 79 | + Extras = new Dictionary<string, string> |
| 80 | + { |
| 81 | + // Set the demographic to an audience with an "Age Range" of 30-34 |
| 82 | + // and an interest in mergers and acquisitions. |
| 83 | + { "IAB_AUDIENCE_1_1", "1, 2, 3, 4, 5" }, |
| 84 | + // Set the content to sedan, station wagon and SUV automotive values. |
| 85 | + { "IAB_AUDIENCE_2_2", "6, 7, 8, 9, 10" } |
| 86 | + } |
| 87 | + }; |
| 88 | + // [END set_publisher_provided_signals] |
| 89 | + } |
| 90 | + } |
| 91 | +} |
0 commit comments