ATiOSBannerJS.ts 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import ATiOSJS from "./ATiOSJS"; // Assuming ATiOSJS is exported as a module
  2. const OC_WRAPPER_CLASS = "ATBannerAdWrapper";
  3. interface AdListener {
  4. // Define the structure of the listener if known
  5. }
  6. interface ShowAdRectangle {
  7. // Define the structure for the rectangle if known
  8. }
  9. const ATiOSBannerJS = {
  10. loadBanner(placementId: string, extra: string): void {
  11. ATiOSJS.printJsLog(`ATiOSBannerJS::loadBanner(${placementId}, ${extra})`);
  12. jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "loadBannerWithPlacementID:extra:", placementId, extra);
  13. },
  14. setAdListener(listener: AdListener): void {
  15. ATiOSJS.printJsLog(`ATiOSBannerJS::setAdListener(${JSON.stringify(listener)})`);
  16. jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "setDelegates:", JSON.stringify(listener));
  17. },
  18. hasAdReady(placementId: string): boolean {
  19. ATiOSJS.printJsLog(`ATiOSBannerJS::hasAdReady(${placementId})`);
  20. return jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "bannerReadyForPlacementID:", placementId);
  21. },
  22. checkAdStatus(placementId: string): string {
  23. ATiOSJS.printJsLog(`ATiOSBannerJS::checkAdStatus(${placementId})`);
  24. return jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "bannerCheckAdStatusForPlacementID:", placementId);
  25. },
  26. showAdInPosition(placementId: string, position: string): void {
  27. ATiOSJS.printJsLog(`ATiOSBannerJS::showAdInPosition(${placementId}, ${position})`);
  28. jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "showBannerWithPlacementID:scene:position:", placementId, null, position);
  29. },
  30. showAdInPositionAndScenario(placementId: string, position: string, scenario: string): void {
  31. ATiOSJS.printJsLog(`ATiOSBannerJS::showAdInPositionAndScenario(${placementId}, ${position}, ${scenario})`);
  32. jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "showBannerWithPlacementID:scene:position:", placementId, scenario, position);
  33. },
  34. showAdInRectangle(placementId: string, showAdRect: ShowAdRectangle): void {
  35. ATiOSJS.printJsLog(`ATiOSBannerJS::showAdInRectangle(${placementId}, ${JSON.stringify(showAdRect)})`);
  36. jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "showBannerWithPlacementID:scene:rect:", placementId, null, showAdRect);
  37. },
  38. showAdInRectangleAndScenario(placementId: string, showAdRect: ShowAdRectangle, scenario: string): void {
  39. ATiOSJS.printJsLog(`ATiOSBannerJS::showAdInRectangleAndScenario(${placementId}, ${JSON.stringify(showAdRect)}, ${scenario})`);
  40. jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "showBannerWithPlacementID:scene:rect:", placementId, scenario, showAdRect);
  41. },
  42. removeAd(placementId: string): void {
  43. ATiOSJS.printJsLog(`ATiOSBannerJS::removeAd(${placementId})`);
  44. jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "removeAd:", placementId);
  45. },
  46. reShowAd(placementId: string): void {
  47. ATiOSJS.printJsLog(`ATiOSBannerJS::reShowAd(${placementId})`);
  48. jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "reShowAd:", placementId);
  49. },
  50. hideAd(placementId: string): void {
  51. ATiOSJS.printJsLog(`ATiOSBannerJS::hideAd(${placementId})`);
  52. jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "hideAd:", placementId);
  53. }
  54. };
  55. export default ATiOSBannerJS;