ATiOSNativeJS.ts 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. const OC_WRAPPER_CLASS = "ATNativeAdWrapper";
  2. import ATiOSJS from "./ATiOSJS";
  3. interface ATiOSNativeJSInterface {
  4. loadNative(placementId: string, settings: string): void;
  5. setAdListener(listener: string): void;
  6. hasAdReady(placementId: string): boolean;
  7. checkAdStatus(placementId: string): boolean;
  8. showAd(placementId: string, adViewProperty: string): void;
  9. showAdInScenario(placementId: string, adViewProperty: string, scenario: string): void;
  10. removeAd(placementId: string): void;
  11. }
  12. const ATiOSNativeJS : ATiOSNativeJSInterface = {
  13. loadNative(placementId: string, settings: string): void {
  14. ATiOSJS.printJsLog(`ATiOSNativeJS::loadNative(${placementId}, ${settings})`);
  15. jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "loadNativeWithPlacementID:extra:", placementId, settings);
  16. },
  17. setAdListener(listener: string): void {
  18. ATiOSJS.printJsLog(`ATiOSNativeJS::setAdListener(${listener})`);
  19. jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "setDelegates:", listener);
  20. },
  21. hasAdReady(placementId: string): boolean {
  22. ATiOSJS.printJsLog(`ATiOSNativeJS::hasAdReady(${placementId})`);
  23. return jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "nativeReadyForPlacementID:", placementId);
  24. },
  25. checkAdStatus(placementId: string): boolean {
  26. ATiOSJS.printJsLog(`ATiOSNativeJS::checkAdStatus(${placementId})`);
  27. return jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "nativeCheckAdStatusForPlacementID:", placementId);
  28. },
  29. showAd(placementId: string, adViewProperty: string): void {
  30. ATiOSJS.printJsLog(`ATiOSNativeJS::showAd(${placementId}, ${adViewProperty})`);
  31. jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "showNativeWithPlacementID:scene:metrics:", placementId, null, adViewProperty);
  32. },
  33. showAdInScenario(placementId: string, adViewProperty: string, scenario: string): void {
  34. ATiOSJS.printJsLog(`ATiOSNativeJS::showAdInScenario(${placementId}, ${adViewProperty}, ${scenario})`);
  35. jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "showNativeWithPlacementID:scene:metrics:", placementId, scenario, adViewProperty);
  36. },
  37. removeAd(placementId: string): void {
  38. ATiOSJS.printJsLog(`ATiOSNativeJS::removeAd(${placementId})`);
  39. jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "removeNativeWithPlacementID:", placementId);
  40. }
  41. };
  42. export default ATiOSNativeJS;