ATiOSRewardedVideoJS.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const OC_RV_WRAPPER_CLASS = "ATRewardedVideoWrapper";
  2. import ATiOSJS from "./ATiOSJS";
  3. interface ATiOSRewardedVideoJSInterface {
  4. loadRewardedVideo(placementId: string, extra: string): void;
  5. setAdListener(listener: string): void;
  6. hasAdReady(placementId: string): boolean;
  7. checkAdStatus(placementId: string): boolean;
  8. setUserData(placementId: string, userId: string, userData: any): void; // Adjust type of userData if needed
  9. showAd(placementId: string): void;
  10. showAdInScenario(placementId: string, scenario: string): void;
  11. }
  12. const ATiOSRewardedVideoJS: ATiOSRewardedVideoJSInterface = {
  13. loadRewardedVideo(placementId: string, extra: string): void {
  14. ATiOSJS.printJsLog(`ATiOSRewardedVideoJS::loadRewardedVideo(${placementId}, ${extra})`);
  15. jsb.reflection.callStaticMethod(OC_RV_WRAPPER_CLASS, "loadRewardedVideoWithPlacementID:extra:", placementId, extra);
  16. },
  17. setAdListener(listener: string): void {
  18. ATiOSJS.printJsLog(`ATiOSRewardedVideoJS::setAdListener(${listener})`);
  19. jsb.reflection.callStaticMethod(OC_RV_WRAPPER_CLASS, "setDelegates:", listener);
  20. },
  21. hasAdReady(placementId: string): boolean {
  22. ATiOSJS.printJsLog(`ATiOSRewardedVideoJS::hasAdReady(${placementId})`);
  23. return jsb.reflection.callStaticMethod(OC_RV_WRAPPER_CLASS, "rewardedVideoReadyForPlacementID:", placementId);
  24. },
  25. checkAdStatus(placementId: string): boolean {
  26. ATiOSJS.printJsLog(`ATiOSRewardedVideoJS::checkAdStatus(${placementId})`);
  27. return jsb.reflection.callStaticMethod(OC_RV_WRAPPER_CLASS, "checkAdStatus:", placementId);
  28. },
  29. setUserData(placementId: string, userId: string, userData: any): void {
  30. cc.log("Android-setUserData");
  31. // Implement functionality if needed
  32. },
  33. showAd(placementId: string): void {
  34. ATiOSJS.printJsLog(`ATiOSRewardedVideoJS::showAd(${placementId})`);
  35. jsb.reflection.callStaticMethod(OC_RV_WRAPPER_CLASS, "showRewardedVideoWithPlacementID:scene:", placementId, null);
  36. },
  37. showAdInScenario(placementId: string, scenario: string): void {
  38. ATiOSJS.printJsLog(`ATiOSRewardedVideoJS::showAdInScenario(${placementId}, ${scenario})`);
  39. jsb.reflection.callStaticMethod(OC_RV_WRAPPER_CLASS, "showRewardedVideoWithPlacementID:scene:", placementId, scenario);
  40. }
  41. };
  42. export default ATiOSRewardedVideoJS;