Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

57 righe
1.7 KiB

  1. // Copyright (C) 2017 Google, Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. using System;
  15. using System.Reflection;
  16. using GoogleMobileAds.Common;
  17. namespace GoogleMobileAds.Api
  18. {
  19. public class MobileAds
  20. {
  21. private static readonly IMobileAdsClient client = GetMobileAdsClient();
  22. public static void Initialize(string appId)
  23. {
  24. client.Initialize(appId);
  25. }
  26. public static void SetApplicationMuted(bool muted)
  27. {
  28. client.SetApplicationMuted(muted);
  29. }
  30. public static void SetApplicationVolume(float volume)
  31. {
  32. client.SetApplicationVolume(volume);
  33. }
  34. public static void SetiOSAppPauseOnBackground(bool pause)
  35. {
  36. client.SetiOSAppPauseOnBackground(pause);
  37. }
  38. private static IMobileAdsClient GetMobileAdsClient()
  39. {
  40. Type googleMobileAdsClientFactory = Type.GetType(
  41. "GoogleMobileAds.GoogleMobileAdsClientFactory,Assembly-CSharp");
  42. MethodInfo method = googleMobileAdsClientFactory.GetMethod(
  43. "MobileAdsInstance",
  44. BindingFlags.Static | BindingFlags.Public);
  45. return (IMobileAdsClient)method.Invoke(null, null);
  46. }
  47. }
  48. }