ATiOSJS.ts 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. const OC_ATSDK_MANAGER_CLASS = "ATSDKManager";
  2. const OC_BRIDGE_CLASS = "ATJSBridge";
  3. interface ATiOSJSInterface {
  4. initSDK(appid: string, appkey: string): void;
  5. initCustomMap(customMap: string): void;
  6. setPlacementCustomMap(placementId: string, customMap: string): void;
  7. setGDPRLevel(level: number): void;
  8. getGDPRLevel(): number;
  9. getUserLocation(callbackMethod: string): void;
  10. showGDPRAuth(): void;
  11. setLogDebug(debug: boolean): void;
  12. printJsLog(msg: string): void;
  13. deniedUploadDeviceInfo(deniedInfo: string): void;
  14. }
  15. const ATiOSJS: ATiOSJSInterface = {
  16. initSDK(appid: string, appkey: string): void {
  17. this.printJsLog(`ATiOSJS::initSDK(${appid}, ${appkey})`);
  18. jsb.reflection.callStaticMethod(OC_ATSDK_MANAGER_CLASS, "startWithAppID:appKey:", appid, appkey);
  19. },
  20. initCustomMap(customMap: string): void {
  21. this.printJsLog(`ATiOSJS::initCustomMap(${customMap})`);
  22. jsb.reflection.callStaticMethod(OC_ATSDK_MANAGER_CLASS, "setCustomData:", customMap);
  23. },
  24. setPlacementCustomMap(placementId: string, customMap: string): void {
  25. this.printJsLog(`ATiOSJS::setPlacementCustomMap(${placementId}, ${customMap})`);
  26. jsb.reflection.callStaticMethod(OC_ATSDK_MANAGER_CLASS, "setCustomData:forPlacementID:", customMap, placementId);
  27. },
  28. setGDPRLevel(level: number): void {
  29. this.printJsLog(`ATiOSJS::setGDPRLevel(${level})`);
  30. jsb.reflection.callStaticMethod(OC_ATSDK_MANAGER_CLASS, "setDataConsent:", level.toString());
  31. },
  32. getGDPRLevel(): number {
  33. this.printJsLog("ATiOSJS::getGDPRLevel()");
  34. return jsb.reflection.callStaticMethod(OC_ATSDK_MANAGER_CLASS, "dataConsent","");
  35. },
  36. getUserLocation(callbackMethod: string): void {
  37. this.printJsLog(`ATiOSJS::getUserLocation(${callbackMethod})`);
  38. jsb.reflection.callStaticMethod(OC_ATSDK_MANAGER_CLASS, "getUserLocationWithCallback:", callbackMethod);
  39. },
  40. showGDPRAuth(): void {
  41. this.printJsLog("ATiOSJS::showGDPRAuth()");
  42. jsb.reflection.callStaticMethod(OC_ATSDK_MANAGER_CLASS, "presentDataConsentDialog","");
  43. },
  44. setLogDebug(debug: boolean): void {
  45. this.printJsLog(`ATiOSJS::setLogDebug(${debug})`);
  46. jsb.reflection.callStaticMethod(OC_ATSDK_MANAGER_CLASS, "setDebugLog:", debug.toString());
  47. },
  48. printJsLog(msg: string): void {
  49. if (msg !== undefined && msg !== null) {
  50. jsb.reflection.callStaticMethod(OC_BRIDGE_CLASS, "log:", msg);
  51. }
  52. },
  53. deniedUploadDeviceInfo(deniedInfo: string): void {
  54. this.printJsLog(`ATiOSJS::deniedUploadDeviceInfo(${deniedInfo})`);
  55. jsb.reflection.callStaticMethod(OC_ATSDK_MANAGER_CLASS, "deniedUploadDeviceInfo:", deniedInfo);
  56. }
  57. };
  58. export default ATiOSJS;