ad_helper.dart 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import 'dart:io';
  2. import 'package:flutter/foundation.dart';
  3. import '../config/config.dart';
  4. class AdHelper {
  5. ////////////////// applovin //////////////////
  6. // applovin ad sdk 初始化需要的sdkkey
  7. static String get applovinSdkKey => 'Re0UgCOtX5ilJER-0B4LpK-5cR4iPs1sU2LAFk1nqlW7zz6-9BJyWI28k6r8yt-RvKc82dwtMQ-KO5IXHcUpvW';
  8. static String get applovinBannerAdUnitId {
  9. if (Platform.isAndroid) {
  10. if (kReleaseMode && !Config.isDebug) return '8bc21670e20e8f18';
  11. return '8bc21670e20e8f18'; // test id
  12. } else if (Platform.isIOS) {
  13. if (kReleaseMode && !Config.isDebug) return '8bc21670e20e8f18';
  14. return '8bc21670e20e8f18'; // test id
  15. } else {
  16. return '8bc21670e20e8f18';
  17. }
  18. }
  19. static String get applovinInterstitialAdUnitId {
  20. if (Platform.isAndroid) {
  21. if (kReleaseMode && !Config.isDebug) return 'ace63b1d8232da10';
  22. return 'ace63b1d8232da10'; // test id
  23. } else if (Platform.isIOS) {
  24. if (kReleaseMode && !Config.isDebug) return 'ace63b1d8232da10';
  25. return 'ace63b1d8232da10'; // test id
  26. } else {
  27. return 'ace63b1d8232da10';
  28. }
  29. }
  30. static String get applovinRewardedAdUnitId {
  31. if (Platform.isAndroid) {
  32. if (kReleaseMode && !Config.isDebug) return '9d218c119bc40d06';
  33. return '9d218c119bc40d06'; // test id
  34. } else if (Platform.isIOS) {
  35. if (kReleaseMode && !Config.isDebug) return '9d218c119bc40d06';
  36. return '9d218c119bc40d06'; // test id
  37. } else {
  38. return '9d218c119bc40d06';
  39. }
  40. }
  41. }
  42. // 定义插屏和激励广告的状态
  43. enum AdState {
  44. // 初始状态,广告未加载
  45. initial,
  46. // 广告已经ready
  47. ready,
  48. // 广告正常显示
  49. showing,
  50. // 广告显示异常
  51. error,
  52. // 广告视窗关闭
  53. dismissed,
  54. }