ATSDKMgrJS.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. require("./AnyThinkAds/ATJSSDK");
  2. var ATSDKMgrJS = cc.Class({
  3. name: "ATSDKMgrJS",
  4. /** 代理脚本(TS) */
  5. proxy: null,
  6. ctor: function () {
  7. console.log("ATSDKMgrJS.js created! ")
  8. },
  9. /** 初始化Sdk */
  10. initATJSSDK: function (appid, appsecret) {
  11. ATJSSDK.setLogDebug(true);
  12. var customMap = {
  13. "appCustomKey1": "appCustomValue1",
  14. "appCustomKey2": "appCustomValue2"
  15. };
  16. ATJSSDK.initCustomMap(customMap);
  17. // ATJSSDK.setPlacementCustomMap(customPlacementId, placementCustomMap);
  18. //替换------------------------------------------------------------------
  19. var placementCustomMap = {
  20. "placementCustomKey1": "placementCustomValue1",
  21. "placementCustomKey2": "placementCustomValue2"
  22. };
  23. ATJSSDK.setPlacementCustomMap(this.placementID(), placementCustomMap);
  24. //ATJSSDK.setGDPRLevel(ATJSSDK.NONPERSONALIZED);
  25. var GDPRLevel = ATJSSDK.getGDPRLevel();
  26. // ATJSSDK.printLog("Current GDPR Level :" + GDPRLevel);
  27. if (cc.sys.os === cc.sys.OS_IOS) {
  28. ATJSSDK.initSDK(appid, appsecret);
  29. } else if (cc.sys.os === cc.sys.OS_ANDROID) {
  30. ATJSSDK.initSDK(appid, appsecret);
  31. }
  32. ATJSSDK.getUserLocation(function (userLocation) {
  33. // ATJSSDK.printLog("getUserLocation callback userLocation :" + userLocation);
  34. if (userLocation === ATJSSDK.kATUserLocationInEU) {
  35. if (ATJSSDK.getGDPRLevel() === ATJSSDK.UNKNOWN) {
  36. ATJSSDK.showGDPRAuth();
  37. }
  38. }
  39. });
  40. },
  41. placementID() {
  42. return this.proxy.placementID();
  43. }
  44. });
  45. module.exports = ATSDKMgrJS;
  46. if (!cc["ATSDKMgrJS"]) {
  47. cc["ATSDKMgrJS"] = new ATSDKMgrJS();
  48. }