ATiOSInterstitialJS.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import ATiOSJS from "./ATiOSJS"; // Assuming ATiOSJS is a module
  2. const OC_WRAPPER_CLASS = "ATInterstitialAdWrapper";
  3. interface AdListener {
  4. // Define the structure of the listener if known
  5. }
  6. const ATiOSInterstitialJS = {
  7. loadInterstitial(placementId: string, extra: string): void {
  8. ATiOSJS.printJsLog(`ATiOSInterstitialJS::loadInterstitial(${placementId}, ${extra})`);
  9. jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "loadInterstitialWithPlacementID:extra:", placementId, extra);
  10. },
  11. setAdListener(listener: AdListener): void {
  12. ATiOSJS.printJsLog(`ATiOSInterstitialJS::setAdListener(${JSON.stringify(listener)})`);
  13. jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "setDelegates:", JSON.stringify(listener));
  14. },
  15. hasAdReady(placementId: string): boolean {
  16. ATiOSJS.printJsLog(`ATiOSInterstitialJS::hasAdReady(${placementId})`);
  17. return jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "interstitialReadyForPlacementID:", placementId);
  18. },
  19. checkAdStatus(placementId: string): string {
  20. ATiOSJS.printJsLog(`ATiOSInterstitialJS::checkAdStatus(${placementId})`);
  21. return jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "checkAdStatus:", placementId);
  22. },
  23. setUserData(placementId: string, userId: string, userData: string): void {
  24. cc.log("iOS-setUserData");
  25. },
  26. showAd(placementId: string): void {
  27. ATiOSJS.printJsLog(`ATiOSInterstitialJS::showAd(${placementId})`);
  28. jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "showInterstitialWithPlacementID:scene:", placementId, null);
  29. },
  30. showAdInScenario(placementId: string, scenario: string): void {
  31. ATiOSJS.printJsLog(`ATiOSInterstitialJS::showAd(${placementId}, ${scenario})`);
  32. jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "showInterstitialWithPlacementID:scene:", placementId, scenario);
  33. }
  34. };
  35. export default ATiOSInterstitialJS;