a8ee46c4-f356-4818-8bc2-b52d7ebf69f3.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. "use strict";
  2. cc._RF.push(module, 'a8ee4bE81ZIGIvCtS1+v2nz', 'AdAgentIOS');
  3. // common-plugin/Scripts/AdAgentIOS.ts
  4. "use strict";
  5. var __extends = (this && this.__extends) || (function () {
  6. var extendStatics = function (d, b) {
  7. extendStatics = Object.setPrototypeOf ||
  8. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  9. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10. return extendStatics(d, b);
  11. };
  12. return function (d, b) {
  13. extendStatics(d, b);
  14. function __() { this.constructor = d; }
  15. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16. };
  17. })();
  18. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  19. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  20. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  21. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  22. return c > 3 && r && Object.defineProperty(target, key, r), r;
  23. };
  24. Object.defineProperty(exports, "__esModule", { value: true });
  25. exports.NativeIosCallBack = void 0;
  26. var AdAgent_1 = require("./AdAgent");
  27. var YZ_Constant_1 = require("./YZ_Constant");
  28. var PlatUtils_1 = require("./PlatUtils");
  29. var Utils_1 = require("./Utils");
  30. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  31. var ST_JNIMessage = "JNIMessage";
  32. var ST_VideoCallback = "VideoCallback";
  33. var AdAgentIOS = /** @class */ (function (_super) {
  34. __extends(AdAgentIOS, _super);
  35. function AdAgentIOS() {
  36. var _this = _super !== null && _super.apply(this, arguments) || this;
  37. _this._className = "JNIHelper";
  38. _this._videoCallback = null;
  39. _this._showBannerTimerId = 0;
  40. return _this;
  41. }
  42. Object.defineProperty(AdAgentIOS.prototype, "ServerConfig", {
  43. get: function () {
  44. return Utils_1.utils.Tool_IOS.ServerConfig;
  45. },
  46. enumerable: false,
  47. configurable: true
  48. });
  49. AdAgentIOS.prototype.Init = function () {
  50. var _this = this;
  51. if (PlatUtils_1.default.IsNativeIOS) {
  52. cc.game.on(ST_JNIMessage, function (event) {
  53. if (event.type == ST_VideoCallback) {
  54. if (_this._videoCallback) {
  55. if (!event.ret) {
  56. _this._videoCallback(event.ret, event.message ? event.message : "视频播放失败!");
  57. }
  58. else {
  59. _this._videoCallback(event.ret);
  60. }
  61. }
  62. }
  63. });
  64. }
  65. };
  66. AdAgentIOS.prototype.ShowBanner = function (location, args) {
  67. if (location === void 0) { location = YZ_Constant_1.BannerLocation.Home; }
  68. if (args === void 0) { args = null; }
  69. if (PlatUtils_1.default.IsNativeIOS) {
  70. Utils_1.utils.showLog("AdAgentNative ShowBanner");
  71. // let interval: number = 18;
  72. // if (this.ServerConfig && this.ServerConfig.refresh_ad_time) {
  73. // interval = this.ServerConfig.refresh_ad_time;
  74. // }
  75. // try {
  76. jsb.reflection.callStaticMethod(this._className, "showBanner:", YZ_Constant_1.BannerLocationToString(location));
  77. // } catch (error) {
  78. // utils.showLog(error);
  79. // }
  80. // clearInterval(this._showBannerTimerId);
  81. // this._showBannerTimerId = setInterval(function () {
  82. // utils.showLog(`定时刷新显示Banner广告!location:${location}; args:${JSON.stringify(args)}; 间隔时间:${interval}`);
  83. // this.ShowBanner(location, args);
  84. // }.bind(this), interval * 1000);
  85. }
  86. };
  87. AdAgentIOS.prototype.HideBanner = function (location) {
  88. if (location === void 0) { location = YZ_Constant_1.BannerLocation.Home; }
  89. clearInterval(this._showBannerTimerId);
  90. jsb.reflection.callStaticMethod(this._className, "hideBanner:", YZ_Constant_1.BannerLocationToString(location));
  91. };
  92. AdAgentIOS.prototype.ShowInterstitial = function () {
  93. var _this = this;
  94. if (PlatUtils_1.default.IsNativeIOS) {
  95. try {
  96. var delayShowTime = 1;
  97. if (this.ServerConfig && this.ServerConfig.intersititia_delay_show_time) {
  98. delayShowTime = this.ServerConfig.intersititia_delay_show_time;
  99. }
  100. Utils_1.utils.showLog("AdAgentNative ShowInterstitial 延迟", delayShowTime, "秒调用!");
  101. Utils_1.utils.delayCall(function () {
  102. jsb.reflection.callStaticMethod(_this._className, "showInterstitial");
  103. }, delayShowTime);
  104. }
  105. catch (error) {
  106. Utils_1.utils.showLog(error);
  107. }
  108. }
  109. };
  110. AdAgentIOS.prototype.ShowVideo = function (callback) {
  111. if (PlatUtils_1.default.IsNativeIOS) {
  112. Utils_1.utils.showLog("AdAgentNative ShowVideo");
  113. this._videoCallback = callback;
  114. try {
  115. jsb.reflection.callStaticMethod(this._className, "showVideo");
  116. }
  117. catch (error) {
  118. Utils_1.utils.showLog(error);
  119. if (callback) {
  120. callback(false);
  121. }
  122. }
  123. }
  124. };
  125. AdAgentIOS.prototype.showFullScreenVideo = function (callback) {
  126. if (PlatUtils_1.default.IsNativeIOS) {
  127. Utils_1.utils.showLog("AdAgentNative ShowVideo");
  128. this._videoCallback = callback;
  129. try {
  130. jsb.reflection.callStaticMethod(this._className, "showFullScreenVideo");
  131. }
  132. catch (error) {
  133. Utils_1.utils.showLog(error);
  134. if (callback) {
  135. callback(false);
  136. }
  137. }
  138. }
  139. };
  140. AdAgentIOS = __decorate([
  141. ccclass
  142. ], AdAgentIOS);
  143. return AdAgentIOS;
  144. }(AdAgent_1.default));
  145. exports.default = AdAgentIOS;
  146. var NativeIosCallBack = /** @class */ (function () {
  147. function NativeIosCallBack() {
  148. }
  149. /**
  150. * 1:播放完成
  151. * 2:播放失败
  152. * 3:无广告
  153. *
  154. */
  155. NativeIosCallBack.videoCallBack = function (result, msg) {
  156. Utils_1.utils.showLog("视频广告回调函数 ------>#result=" + result + " #msg=" + msg ? msg : "");
  157. if (result == "1") {
  158. //播放成功
  159. cc.game.emit(ST_JNIMessage, { type: ST_VideoCallback, ret: true });
  160. }
  161. else {
  162. //播放失败
  163. cc.game.emit(ST_JNIMessage, { type: ST_VideoCallback, ret: false, message: msg });
  164. }
  165. };
  166. return NativeIosCallBack;
  167. }());
  168. exports.NativeIosCallBack = NativeIosCallBack;
  169. window["NativeIosCallBack"] = NativeIosCallBack;
  170. cc._RF.pop();