ad_helper.dart 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import 'dart:io';
  2. class AdHelper {
  3. ////////////////// applovin //////////////////
  4. // applovin ad sdk 初始化需要的sdkkey
  5. static String applovinSdkKey = 'mycRUJHDmgMv3i2NFQ5L5rB_T2y4HBOIIFR7_gpPd3bDCLep4Bb_KfWTsdWTrafiKMQMOyuAGFDOTTmagsk4LM';
  6. // 根据是否 lite 版本返回对应的 banner 广告位
  7. static String getApplovinBannerUnitId(bool isLite) {
  8. if (Platform.isAndroid) {
  9. return isLite ? '763f7bbf8e3fe737' : '0c6a650f98d3832e';
  10. } else if (Platform.isIOS) {
  11. return '';
  12. } else {
  13. return '';
  14. }
  15. }
  16. // 原有 full banner 广告位
  17. static String get applovinBannerAdUnitId {
  18. if (Platform.isAndroid) {
  19. return '0c6a650f98d3832e';
  20. } else if (Platform.isIOS) {
  21. return '';
  22. } else {
  23. return '';
  24. }
  25. }
  26. // lite banner 广告位
  27. static String get applovinBannerAdUnitIdLite {
  28. if (Platform.isAndroid) {
  29. return '763f7bbf8e3fe737';
  30. } else if (Platform.isIOS) {
  31. return '';
  32. } else {
  33. return '';
  34. }
  35. }
  36. // 原有 full 插屏广告位
  37. static String get applovinInterstitialAdUnitId {
  38. if (Platform.isAndroid) {
  39. return 'd072aec9f9a9b4a4';
  40. } else if (Platform.isIOS) {
  41. return '';
  42. } else {
  43. return '';
  44. }
  45. }
  46. // lite 插屏广告位
  47. static String get applovinInterstitialAdUnitIdLite {
  48. if (Platform.isAndroid) {
  49. return '4d06a16999128cca';
  50. } else if (Platform.isIOS) {
  51. return '';
  52. } else {
  53. return '';
  54. }
  55. }
  56. // 根据是否 lite 版本返回对应的 插屏 广告位
  57. static String getApplovinInterstitialUnitId(bool isLite) {
  58. if (Platform.isAndroid) {
  59. return isLite ? '4d06a16999128cca' : 'd072aec9f9a9b4a4';
  60. } else if (Platform.isIOS) {
  61. return '';
  62. } else {
  63. return '';
  64. }
  65. }
  66. // 记录广告位
  67. static String get applovinRewardedAdUnitId {
  68. if (Platform.isAndroid) {
  69. return '4e4bf93a3a0314d8';
  70. } else if (Platform.isIOS) {
  71. return '';
  72. } else {
  73. return '';
  74. }
  75. }
  76. }
  77. // 定义插屏和激励广告的状态
  78. enum AdState {
  79. // 初始状态,广告未加载
  80. initial,
  81. // 广告已经ready
  82. ready,
  83. // 广告正常显示
  84. showing,
  85. // 广告显示异常
  86. error,
  87. // 广告视窗关闭
  88. dismissed,
  89. }