toponad.d.ts 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908
  1. declare namespace topon {
  2. interface ParamMap {
  3. os_vn?: string;
  4. os_vc?: string;
  5. package_name?: string;
  6. app_vn?: string;
  7. app_vc?: string;
  8. brand?: string;
  9. model?: string;
  10. screen?: string;
  11. mnc?: string;
  12. mcc?: string;
  13. language?: string;
  14. timezone?: string;
  15. ua?: string;
  16. orient?: string;
  17. network_type?: string;
  18. it_src?: string;
  19. android_id?: string;
  20. gaid?: string;
  21. mac?: string;
  22. imei?: string;
  23. oaid?: string;
  24. idfa?: string;
  25. idfv?: string;
  26. [name: string]: any;
  27. }
  28. type UserLocationCallback = (status: 0 | 1 | 2) => void;
  29. enum GDPRLevel {
  30. PERSONALIZED = 0,
  31. NONPERSONALIZED = 1,
  32. UNKNOWN = 2
  33. }
  34. interface AdInfo {
  35. /**
  36. * @en
  37. * A unique ID generated every time an ad is displayed
  38. * @zh
  39. * 每次展示广告时生成的独立ID
  40. */
  41. id: number;
  42. /**
  43. * @en
  44. * Display income, the unit can be obtained by currency, and the precision can be obtained by precision
  45. * @zh
  46. * 展示收益,单位可通过 currency 获取, 精度可通过 precision 获取
  47. */
  48. publisher_revenue: number;
  49. /**
  50. * @en
  51. * Currency unit, for example: "USD"
  52. * @zh
  53. * 货币单位,例如:"USD"
  54. */
  55. currency: string;
  56. /**
  57. * @en
  58. * Country code, for example: "CN"
  59. * @zh
  60. * 国家代码, 例如:”CN"
  61. */
  62. country: string;
  63. /**
  64. * @en
  65. * TopOn Advertising Slot ID
  66. * @zh
  67. * TopOn 广告位ID
  68. */
  69. adunit_id: string;
  70. /**
  71. * @en
  72. * Advertising types, including: "Native", "RewardedVideo", "Banner", "Interstitial", "Splash"
  73. * @zh
  74. * 广告类型,包括:"Native"、"RewardedVideo"、"Banner"、"Interstitial"、"Splash"
  75. */
  76. adunit_format: "Native" | "RewardedVideo" | "Banner" | "Interstitial" | "Splash";
  77. /**
  78. * @en
  79. * ECPM accuracy
  80. *
  81. * "publisher_defined": The eCPM defined by the developer for the advertising source in the TopOn backend (cross-promotion eCPM also belongs to this type)
  82. *
  83. * "estimated": The eCPM calculated by TopOn based on historical data after the automatic price function of advertising sources is turned on in the TopOn background
  84. *
  85. * "exact": eCPM for real-time bidding
  86. * @zh
  87. * ECPM精度
  88. *
  89. * "publisher_defined":开发者在TopOn后台为广告源定义的eCPM(交叉推广的eCPM也属于该类型)
  90. *
  91. * "estimated": 在TopOn后台开启广告源的自动价格功能后,TopOn根据历史数据计算出的eCPM
  92. *
  93. * "exact":实时竞价的eCPM
  94. */
  95. precision: "publisher_defined" | "estimated" | "exact";
  96. /**
  97. * @en
  98. * Network type
  99. *
  100. * "Network": Third-party advertising platform
  101. *
  102. * "Cross_Promotion": Interactive promotion
  103. *
  104. * "Adx": TopOn Adx
  105. * @zh
  106. * Network类型
  107. *
  108. * "Network":第三方广告平台
  109. *
  110. * "Cross_Promotion":交互推广
  111. *
  112. * "Adx":TopOn Adx
  113. */
  114. network_type: "Network" | "Cross_Promotion" | "Adx";
  115. /**
  116. * @en
  117. * @zh
  118. * 广告平台的广告位 ID
  119. */
  120. network_placement_id: string;
  121. /**
  122. * @en
  123. * Ad slot ID of the advertising platform
  124. * @zh
  125. * 广告源的eCPM层级(对应开发者后台聚合管理页面的优先级),头部竞价广告源默认为0
  126. */
  127. ecpm_level: number;
  128. /**
  129. * @en
  130. * Traffic group ID
  131. * @zh
  132. * 流量分组 ID
  133. */
  134. segment_id: number;
  135. /**
  136. * @en
  137. * @zh
  138. * 广告场景 ID,仅 RewardVideo、Interstitial 支持
  139. */
  140. scenario_id: string;
  141. /**
  142. * @en
  143. * Ad scene ID, only supported by RewardVideo and Interstitial
  144. * @zh
  145. * 广告场景的激励名称,仅 RewardeVideo 支持
  146. */
  147. scenario_reward_name: string;
  148. /**
  149. * @en
  150. * The number of incentives for advertising scenes, only supported by RewardVideo
  151. * @zh
  152. * 广告场景的激励数量,仅 RewardVideo 支持
  153. */
  154. scenario_reward_number: number;
  155. /**
  156. * @en
  157. * Channel information
  158. * @zh
  159. * 渠道信息
  160. */
  161. channel: string;
  162. /**
  163. * @en
  164. * Json string of custom rule of Placement+App dimension
  165. * @zh
  166. * Placement+App维度的自定义规则的Json字符串
  167. */
  168. sub_channel: string;
  169. /**
  170. * @en
  171. * Custom rules of Placement+App dimension
  172. * @zh
  173. * Placement+App维度的自定义规则
  174. */
  175. custom_rule: {
  176. [name: string]: any;
  177. };
  178. /**
  179. * @en
  180. * The ID corresponding to the advertising platform, used to distinguish the advertising platform. Refer to https://docs.toponad.com/#/zh-cn/android/android_doc/android_sdk_callback_access?id=network_firm_id
  181. * @zh
  182. * 广告平台对应的ID,用于区分广告平台,参考 https://docs.toponad.com/#/zh-cn/android/android_doc/android_sdk_callback_access?id=network_firm_id
  183. */
  184. network_firm_id: number;
  185. /**
  186. * @en
  187. * Advertising source ID. The specific network information can be queried through the advertising source ID in the developer background or TopOn Open API
  188. * @zh
  189. * 广告源 ID. 可在开发者后台或 TopOn Open API 通过广告源 ID 查询具体的 Network 信息
  190. */
  191. adsource_id: string;
  192. /**
  193. * @en
  194. * The current ranking of ad sources in WaterFall (starting from 0, 0 has the highest priority)
  195. * @zh
  196. * 当前广告源在 WaterFall 中的排序(从0开始,0优先级最高)
  197. */
  198. adsource_index: number;
  199. /**
  200. * @en
  201. * eCPM, currency acquisition, precision can be acquired through precision
  202. * @zh
  203. * eCPM,currency 获取, 精度可通过 precision 获取
  204. */
  205. adsource_price: number;
  206. /**
  207. * @en
  208. * Whether it is the advertising source of the head bidding, 1: Yes, 2: No
  209. * @zh
  210. * 是否为头部竞价的广告源,1:是,2:否
  211. */
  212. adsource_isheaderbidding: 1 | 2;
  213. /**
  214. * @en
  215. * Advertising custom information, for Adx, OnlineAPI and custom advertising platform, Adx, OnlineAPI related key reference
  216. * @zh
  217. * 广告的自定义信息,针对Adx、OnlineAPI以及自定义广告平台,Adx、OnlineAPI相关Key参考
  218. */
  219. ext_info: {
  220. /**
  221. * @en
  222. * Advertising ID of Adx & OnlineAPI Offer
  223. * @zh
  224. * Adx & OnlineAPI Offer的广告 ID
  225. */
  226. offer_id: string;
  227. /**
  228. * @en
  229. * Material ID of Adx & OnlineAPI Offer
  230. * @zh
  231. * Adx & OnlineAPI Offer的素材 ID
  232. */
  233. creative_id: string;
  234. /**
  235. * @en
  236. * Determine whether the order type of Adx & OnlineAPI Offer is a Deeplink or JumpURL order 0: No, 1: Yes
  237. * @zh
  238. * 判断Adx & OnlineAPI Offer的单子类型是否为Deeplink或JumpURL的单子 0: 否、1: 是
  239. */
  240. is_deeplink: 0 | 1;
  241. network_id: string;
  242. network_unit_id: string;
  243. network_ecpm: string;
  244. [name: string]: any;
  245. };
  246. reward_custom_data: {
  247. [name: string]: any;
  248. };
  249. }
  250. interface AdStatus {
  251. isLoading: boolean;
  252. isReady: boolean;
  253. adInfo: AdInfo;
  254. }
  255. interface BannerListener {
  256. onBannerAdLoaded?: () => void;
  257. onBannerAdFailed?: (errorInfo: any) => void;
  258. onBannerAdClicked?: (adInfo: AdInfo) => void;
  259. onBannerAdShow?: (adInfo: AdInfo) => void;
  260. onBannerAdClose?: (adInfo: AdInfo) => void;
  261. onBannerAdAutoRefreshed?: (adInfo: AdInfo) => void;
  262. onBannerAdAutoRefreshFail?: (errorInfo: any) => void;
  263. onBannerAdCloseButtonTapped?: (adInfo: AdInfo) => void;
  264. onDeeplinkCallback?: (adInfo: AdInfo, isSuccess: boolean) => void;
  265. }
  266. interface InterstitialListener {
  267. onInterstitialAdLoaded?: () => void;
  268. onInterstitialAdLoadFail?: (errorInfo: any) => void;
  269. onInterstitialAdClicked?: (adInfo: AdInfo) => void;
  270. onInterstitialAdShow?: (adInfo: AdInfo) => void;
  271. onInterstitialAdClose?: (adInfo: AdInfo) => void;
  272. onInterstitialAdVideoStart?: (adInfo: AdInfo) => void;
  273. onInterstitialAdVideoEnd?: (adInfo: AdInfo) => void;
  274. onInterstitialAdVideoError?: (errorInfo: any) => void;
  275. onInterstitialAdFailedToShow?: (errorInfo: any, adInfo: AdInfo) => void;
  276. onDeeplinkCallback?: (adInfo: AdInfo, isSuccess: boolean) => void;
  277. }
  278. interface NativeListener {
  279. onNativeAdLoaded?: () => void;
  280. onNativeAdLoadFail?: (errorInfo: any) => void;
  281. onNativeAdShow?: (adInfo: AdInfo) => void;
  282. onNativeAdClick?: (adInfo: AdInfo) => void;
  283. onNativeAdVideoStart?: () => void;
  284. onNativeAdVideoEnd?: () => void;
  285. onNativeAdVideoProgress?: (progress: number) => void;
  286. onNativeAdCloseButtonClick?: (adInfo: AdInfo) => void;
  287. onDeeplinkCallback?: (adInfo: AdInfo, isSuccess: boolean) => void;
  288. }
  289. interface RewardVideoListener {
  290. onRewardedVideoAdLoaded?: () => void;
  291. onRewardedVideoAdFailed?: (errorInfo: any) => void;
  292. onRewardedVideoAdPlayStart?: (adInfo: AdInfo) => void;
  293. onRewardedVideoAdPlayEnd?: (adInfo: AdInfo) => void;
  294. onRewardedVideoAdPlayFailed?: (errorInfo: any, adInfo: AdInfo) => void;
  295. onRewardedVideoAdClosed?: (adInfo: AdInfo) => void;
  296. onRewardedVideoAdPlayClicked?: (adInfo: AdInfo) => void;
  297. onReward?: (adInfo: AdInfo) => void;
  298. onDeeplinkCallback?: (adInfo: AdInfo, isSuccess: boolean) => void;
  299. }
  300. class NativeViewItem {
  301. x: number;
  302. y: number;
  303. width: number;
  304. height: number;
  305. backgroundColor: string;
  306. textColor: string;
  307. textSize: number;
  308. constructor(x: number, y: number, width: number, height: number, backgroundColor: string, textColor: string, textSize: number);
  309. }
  310. class NativeViewProperty {
  311. parent: NativeViewItem | undefined;
  312. appIcon: NativeViewItem | undefined;
  313. mainImage: NativeViewItem | undefined;
  314. title: NativeViewItem | undefined;
  315. desc: NativeViewItem | undefined;
  316. adLogo: NativeViewItem | undefined;
  317. cta: NativeViewItem | undefined;
  318. rating: NativeViewItem | undefined;
  319. }
  320. namespace JSB {
  321. function fullClassName(sampleClassName: string): string;
  322. function callNativeMethod(className: string, methodName: string, ...parameters: any): any;
  323. function isAndroid(): boolean;
  324. function isIOS(): boolean;
  325. }
  326. namespace Base {
  327. interface Base {
  328. getPlacementId(): string;
  329. }
  330. interface Banner extends Base {
  331. loadBanner(settings: string): void;
  332. isAdReady(): boolean;
  333. showAdInPosition(position: string): void;
  334. showAdInRectangle(rect: string): void;
  335. removeAd(): void;
  336. reshowAd(): void;
  337. hideAd(): void;
  338. }
  339. interface RewardVideo extends Base {
  340. loadRewardVideo(settings: string): void;
  341. showAd(scenario?: string): void;
  342. isAdReady(): boolean;
  343. checkAdStatus(): string;
  344. }
  345. interface Interstitial extends Base {
  346. loadInterstitial(settings: string): void;
  347. showAd(scenario?: string): void;
  348. isAdReady(): boolean;
  349. checkAdStatus(): string;
  350. }
  351. interface Native extends Base {
  352. loadNative(settings: string): void;
  353. isAdReady(): boolean;
  354. showAd(adViewProperty: string): void;
  355. removeAd(): void;
  356. clean(): void;
  357. }
  358. interface TopOnAd {
  359. initCustomMap(customMap: string): void;
  360. setPlacementCustomMap(placmentId: string, customMap: string): void;
  361. setGDPRLevel(level: number): void;
  362. getGDPRLevel(): number;
  363. getUserLocation(): void;
  364. showGDPRAuth(): void;
  365. setLogDebug(debug: boolean): void;
  366. deniedUploadDeviceInfo(deniedInfo: string): void;
  367. integrationChecking(): void;
  368. }
  369. }
  370. namespace Android {
  371. class Banner implements Base.Banner {
  372. placementId: string;
  373. className: string;
  374. constructor(placementId: string);
  375. getPlacementId(): string;
  376. loadBanner(settings: string): void;
  377. isAdReady(): boolean;
  378. showAdInPosition(position: string): void;
  379. showAdInRectangle(rect: string): void;
  380. removeAd(): void;
  381. reshowAd(): void;
  382. hideAd(): void;
  383. }
  384. class Interstitial implements Base.Interstitial {
  385. placementId: string;
  386. className: string;
  387. constructor(placementId: string);
  388. getPlacementId(): string;
  389. loadInterstitial(settings: string): void;
  390. showAd(scenario?: string): void;
  391. isAdReady(): boolean;
  392. checkAdStatus(): string;
  393. }
  394. class Native implements Base.Native {
  395. placementId: string;
  396. className: string;
  397. constructor(placementId: string);
  398. getPlacementId(): string;
  399. loadNative(settings: string): void;
  400. isAdReady(): boolean;
  401. showAd(adViewProperty: string): void;
  402. removeAd(): void;
  403. clean(): void;
  404. }
  405. class RewardVideo implements Base.RewardVideo {
  406. placementId: string;
  407. className: string;
  408. constructor(placementId: string);
  409. getPlacementId(): string;
  410. loadRewardVideo(settings: string): void;
  411. showAd(scenario?: string): void;
  412. isAdReady(): boolean;
  413. checkAdStatus(): string;
  414. }
  415. class TopOnAd implements Base.TopOnAd {
  416. className: string;
  417. constructor();
  418. initCustomMap(customMap: string): void;
  419. setPlacementCustomMap(placmentId: string, customMap: string): void;
  420. setGDPRLevel(level: number): void;
  421. getGDPRLevel(): number;
  422. getUserLocation(): void;
  423. showGDPRAuth(): void;
  424. setLogDebug(debug: boolean): void;
  425. deniedUploadDeviceInfo(deniedInfo: string): void;
  426. integrationChecking(): void;
  427. }
  428. }
  429. namespace iOS {
  430. class Banner implements Base.Banner {
  431. placementId: string;
  432. className: string;
  433. constructor(placementId: string);
  434. getPlacementId(): string;
  435. loadBanner(settings: string): void;
  436. isAdReady(): boolean;
  437. showAdInPosition(position: string): void;
  438. showAdInRectangle(rect: string): void;
  439. removeAd(): void;
  440. reshowAd(): void;
  441. hideAd(): void;
  442. }
  443. class Interstitial implements Base.Interstitial {
  444. placementId: string;
  445. className: string;
  446. constructor(placementId: string);
  447. getPlacementId(): string;
  448. loadInterstitial(settings: string): void;
  449. showAd(scenario?: string): void;
  450. isAdReady(): boolean;
  451. checkAdStatus(): string;
  452. }
  453. class Native implements Base.Native {
  454. placementId: string;
  455. className: string;
  456. constructor(placementId: string);
  457. getPlacementId(): string;
  458. loadNative(settings: string): void;
  459. isAdReady(): boolean;
  460. showAd(adViewProperty: string): void;
  461. removeAd(): void;
  462. clean(): void;
  463. }
  464. class RewardVideo implements Base.RewardVideo {
  465. placementId: string;
  466. className: string;
  467. constructor(placementId: string);
  468. getPlacementId(): string;
  469. loadRewardVideo(settings: string): void;
  470. showAd(scenario?: string): void;
  471. isAdReady(): boolean;
  472. checkAdStatus(): string;
  473. }
  474. class TopOnAd implements Base.TopOnAd {
  475. className: string;
  476. constructor();
  477. initCustomMap(customMap: string): void;
  478. setPlacementCustomMap(placmentId: string, customMap: string): void;
  479. setGDPRLevel(level: number): void;
  480. getGDPRLevel(): number;
  481. getUserLocation(): void;
  482. showGDPRAuth(): void;
  483. setLogDebug(debug: boolean): void;
  484. deniedUploadDeviceInfo(deniedInfo: string): void;
  485. integrationChecking(): void;
  486. }
  487. }
  488. namespace Listener {
  489. function parseCallbackInfo(callbackInfo: string): AdInfo;
  490. const TopOn: {
  491. userLocationCallback: UserLocationCallback;
  492. setCallback(cb: UserLocationCallback): void;
  493. onUserLocation(status: 0 | 1 | 2): void;
  494. };
  495. const Banner: {
  496. listenerMap: Map<string, BannerListener>;
  497. setListener(placementId: string, listener: BannerListener): void;
  498. onBannerAdLoaded(placementId: string): void;
  499. onBannerAdFailed(placementId: string, errorInfo: string): void;
  500. onBannerAdClicked(placementId: string, callbackInfo: string): void;
  501. onBannerAdShow(placementId: string, callbackInfo: string): void;
  502. onBannerAdClose(placementId: string, callbackInfo: string): void;
  503. onBannerAdAutoRefreshed(placementId: string, callbackInfo: string): void;
  504. onBannerAdAutoRefreshFail(placementId: string, errorInfo: string): void;
  505. onBannerAdCloseButtonTapped(placementId: string, callbackInfo: string): void;
  506. onDeeplinkCallback(placementId: string, callbackInfo: string, isSuccess: string): void;
  507. };
  508. const Interstitial: {
  509. listenerMap: Map<string, InterstitialListener>;
  510. setListener(placementId: string, listener: InterstitialListener): void;
  511. onInterstitialAdLoaded(placementId: string): void;
  512. onInterstitialAdLoadFail(placementId: string, errorInfo: string): void;
  513. onInterstitialAdClicked(placementId: string, callbackInfo: string): void;
  514. onInterstitialAdShow(placementId: string, callbackInfo: string): void;
  515. onInterstitialAdClose(placementId: string, callbackInfo: string): void;
  516. onInterstitialAdVideoStart(placementId: string, callbackInfo: string): void;
  517. onInterstitialAdVideoEnd(placementId: string, callbackInfo: string): void;
  518. onInterstitialAdVideoError(placementId: string, errorInfo: string): void;
  519. onInterstitialAdFailedToShow(placementId: string, errorInfo: string, callbackInfo: string): void;
  520. onDeeplinkCallback(placementId: string, callbackInfo: string, isSuccess: string): void;
  521. };
  522. const Native: {
  523. listenerMap: Map<string, NativeListener>;
  524. setListener(placementId: string, listener: NativeListener): void;
  525. onNativeAdLoaded(placementId: string): void;
  526. onNativeAdLoadFail(placementId: string, errorInfo: string): void;
  527. onNativeAdShow(placementId: string, callbackInfo: string): void;
  528. onNativeAdClick(placementId: string, callbackInfo: string): void;
  529. onNativeAdVideoStart(placementId: string): void;
  530. onNativeAdVideoEnd(placementId: string): void;
  531. onNativeAdVideoProgress(placementId: string, progress: string): void;
  532. onNativeAdCloseButtonClick(placementId: string, callbackInfo: string): void;
  533. onDeeplinkCallback(placementId: string, callbackInfo: string, isSuccess: string): void;
  534. };
  535. const RewardVideo: {
  536. listenerMap: Map<string, RewardVideoListener>;
  537. setListener(placementId: string, listener: RewardVideoListener): void;
  538. onRewardedVideoAdLoaded(placementId: string): void;
  539. onRewardedVideoAdFailed(placementId: string, errorInfo: string): void;
  540. onRewardedVideoAdPlayStart(placementId: string, callbackInfo: string): void;
  541. onRewardedVideoAdPlayEnd(placementId: string, callbackInfo: string): void;
  542. onRewardedVideoAdPlayFailed(placementId: string, errorInfo: string, callbackInfo: string): void;
  543. onRewardedVideoAdClosed(placementId: string, callbackInfo: string): void;
  544. onRewardedVideoAdPlayClicked(placementId: string, callbackInfo: string): void;
  545. onReward(placementId: string, callbackInfo: string): void;
  546. onDeeplinkCallback(placementId: string, callbackInfo: string, isSuccess: string): void;
  547. };
  548. }
  549. class Banner {
  550. banner: Base.Banner | undefined;
  551. constructor(placementId: string);
  552. /**
  553. * @en
  554. * Load ad
  555. * @zh
  556. * 加载广告
  557. * @param settings Additional settings for ads
  558. */
  559. loadBanner(settings?: {
  560. banner_ad_size_struct?: {
  561. width: number;
  562. height: number;
  563. };
  564. width?: number;
  565. height?: number;
  566. adaptive_width?: number;
  567. adaptive_orientation?: 0 | 1 | 2;
  568. inline_adaptive_width?: number;
  569. inline_adaptive_orientation?: 0 | 1 | 2;
  570. }): void;
  571. /**
  572. * @en
  573. * Check if the ad is ready
  574. * @zh
  575. * 检查广告是否准备就绪
  576. * @returns Is it ready
  577. */
  578. isAdReady(): boolean;
  579. /**
  580. * @en
  581. * Show ads in designated locations
  582. * @zh
  583. * 在指定的位置显示广告
  584. * @param position Display position
  585. */
  586. showAdInPosition(position: 'top' | 'bottom'): void;
  587. /**
  588. * @en
  589. * Display ads in the designated advertising area
  590. * @zh
  591. * 在指定的广告区域显示广告
  592. * @param rect Display area
  593. */
  594. showAdInRectangle(rect: {
  595. x: number;
  596. y: number;
  597. width: number;
  598. height: number;
  599. }): void;
  600. /**
  601. * @en
  602. * Remove ads
  603. * @zh
  604. * 移除广告
  605. */
  606. removeAd(): void;
  607. /**
  608. * @en
  609. * Redisplay the ad after hiding it
  610. * @zh
  611. * 在隐藏之后重新显示广告
  612. */
  613. reshowAd(): void;
  614. /**
  615. * @en
  616. * Hide ads
  617. * @zh
  618. * 隐藏广告
  619. */
  620. hideAd(): void;
  621. /**
  622. * @en
  623. * Set up ad listener
  624. * @zh
  625. * 设置广告监听器
  626. * @param listener Ad listener
  627. */
  628. setAdListener(listener: BannerListener): void;
  629. }
  630. class Interstitial {
  631. interstitial: Base.Interstitial | undefined;
  632. constructor(placementId: string);
  633. /**
  634. * @en
  635. * Load ad
  636. * @zh
  637. * 加载广告
  638. * @param settings Additional settings for ads
  639. */
  640. loadInterstitial(settings?: {
  641. UseRewardedVideoAsInterstitial: boolean;
  642. }): void;
  643. /**
  644. * @en
  645. * Show ads
  646. * @zh
  647. * 显示广告
  648. * @param scenario Advertising scene
  649. */
  650. showAd(scenario?: string): void;
  651. /**
  652. * @en
  653. * Check if the ad is ready
  654. * @zh
  655. * 检查广告是否准备就绪
  656. * @returns Is it ready
  657. */
  658. isAdReady(): boolean;
  659. /**
  660. * @en
  661. * Get the ad status information of the current ad
  662. * @zh
  663. * 获取当前广告的广告状态信息
  664. * @returns Ad status
  665. */
  666. checkAdStatus(): AdStatus | undefined;
  667. /**
  668. * @en
  669. * Set up ad listener
  670. * @zh
  671. * 设置广告监听器
  672. * @param listener Ad listener
  673. */
  674. setAdListener(listener: InterstitialListener): void;
  675. }
  676. class Native {
  677. native: Base.Native | undefined;
  678. constructor(placementId: string);
  679. /**
  680. * @en
  681. * Load ad
  682. * @zh
  683. * 加载广告
  684. * @param settings Additional settings for ads
  685. */
  686. loadNative(settings?: {
  687. width: number;
  688. height: number;
  689. }): void;
  690. /**
  691. * @en
  692. * Check if the ad is ready
  693. * @zh
  694. * 检查广告是否准备就绪
  695. * @returns Is it ready
  696. */
  697. isAdReady(): boolean;
  698. /**
  699. * @en
  700. * Show ads
  701. * @zh
  702. * 显示广告
  703. * @param adViewProperty Advertisement display interface configuration
  704. */
  705. showAd(adViewProperty: NativeViewProperty): void;
  706. /**
  707. * @en
  708. * Remove ads
  709. * @zh
  710. * 移除广告
  711. */
  712. removeAd(): void;
  713. /**
  714. * @en
  715. * Remove the binding of the ad
  716. * @zh
  717. * 移除广告的绑定
  718. */
  719. clean(): void;
  720. /**
  721. * @en
  722. * Set up ad listener
  723. * @zh
  724. * 设置广告监听器
  725. * @param listener Ad listener
  726. */
  727. setAdListener(listener: NativeListener): void;
  728. }
  729. class RewardVideo {
  730. rewardVideo: Base.RewardVideo | undefined;
  731. constructor(placementId: string);
  732. /**
  733. * @en
  734. * Load ad
  735. * @zh
  736. * 加载广告
  737. * @param settings Additional settings for ads
  738. */
  739. loadRewardVideo(settings?: {
  740. userID: string;
  741. media_ext: string;
  742. }): void;
  743. /**
  744. * @en
  745. * Show ads
  746. * @zh
  747. * 显示广告
  748. * @param scenario Advertising scene
  749. */
  750. showAd(scenario?: string): void;
  751. /**
  752. * @en
  753. * Check if the ad is ready
  754. * @zh
  755. * 检查广告是否准备就绪
  756. * @returns Is it ready
  757. */
  758. isAdReady(): boolean;
  759. /**
  760. * @en
  761. * @zh
  762. * 获取当前广告的广告状态信息
  763. * @returns 广告状态
  764. */
  765. checkAdStatus(): AdStatus | undefined;
  766. /**
  767. * @en
  768. * Set up ad listener
  769. * @zh
  770. * 设置广告监听器
  771. * @param listener Ad listener
  772. */
  773. setAdListener(listener: RewardVideoListener): void;
  774. }
  775. class TopOnAd {
  776. toponAd: Base.TopOnAd | undefined;
  777. constructor();
  778. /**
  779. * @en
  780. * The custom rules of the App are global settings and are valid for all Placements.
  781. *
  782. * Developers can set corresponding custom rules in the traffic grouping in the TopOn background, refer to the traffic grouping instructions (https://docs.toponad.com/#/zh-cn/android/NetworkAccess/SegmentAccess/segment_access_doc.md )
  783. * @zh
  784. * App的自定义规则为全局设置,对全部Placement有效.
  785. *
  786. * 开发者可以在TopOn后台的流量分组中设置相应的自定义规则,具体 参考流量分组使用说明(https://docs.toponad.com/#/zh-cn/android/NetworkAccess/SegmentAccess/segment_access_doc.md)
  787. * @param customMap Custom key-value, which can be used to match the advertisement list information issued by the backend in App dimension
  788. */
  789. initCustomMap(customMap: ParamMap): void;
  790. /**
  791. * @en
  792. * Only valid for the current Placement, you can add custom rules specific to the Placement on the basis of the App custom rules.
  793. *
  794. * Developers can set corresponding custom rules in the traffic grouping in the TopOn background, refer to the traffic grouping instructions (https://docs.toponad.com/#/zh-cn/android/NetworkAccess/SegmentAccess/segment_access_doc.md )
  795. * @zh
  796. * 仅对当前Placement有效,您可以在App自定义规则基础上增加Placement特有的自定义规则.
  797. *
  798. * 开发者可以在TopOn后台的流量分组中设置相应的自定义规则,具体 参考流量分组使用说明(https://docs.toponad.com/#/zh-cn/android/NetworkAccess/SegmentAccess/segment_access_doc.md)
  799. * @param placmentId Current placementId
  800. * @param customMap Custom key-value, which can be used to match the advertisement list information issued by the backend in App dimension
  801. */
  802. setPlacementCustomMap(placmentId: string, customMap: ParamMap): void;
  803. /**
  804. * @en
  805. * Set the reporting level of data under GDPR
  806. * @zh
  807. * 设置 GDPR 下数据的上报等级
  808. * @param level level
  809. */
  810. setGDPRLevel(level: GDPRLevel): void;
  811. /**
  812. * @en
  813. * Get the current escalation level
  814. * @zh
  815. * 获取当前的上报等级
  816. * @returns Current escalation level
  817. */
  818. getGDPRLevel(): GDPRLevel;
  819. /**
  820. * @en
  821. * Check the current network area
  822. * @zh
  823. * 检查当前的网络的区域
  824. * @param callback Callback
  825. */
  826. getUserLocation(callback: UserLocationCallback): void;
  827. /**
  828. * @en
  829. * Display the GDPR authorization page
  830. * @zh
  831. * 展示GDPR授权页面
  832. */
  833. showGDPRAuth(): void;
  834. /**
  835. * @en
  836. * Set whether there is Debug log output. It is recommended to open during the testing phase to facilitate verification of the advertising callback status
  837. * @zh
  838. * 设置是否有Debug日志输出。建议在测试阶段打开,方便验证广告回调状态
  839. * @param debug Whether to output log
  840. */
  841. setLogDebug(debug: boolean): void;
  842. /**
  843. * @en
  844. * Limit the collection of private data,
  845. *
  846. * For iOS see https://docs.toponad.com/#/zh-cn/ios/ios_doc/ios_sdk_init_access?id=_6-%e9%9a%90%e7%a7%81%e6%95%b0%e6% 8d%ae%e8%af%b4%e6%98%8e
  847. *
  848. * Android see https://docs.toponad.com/#/zh-cn/android/android_doc/android_sdk_init_access
  849. * @zh
  850. *
  851. * 限制隐私数据收集,
  852. *
  853. * iOS 参见 https://docs.toponad.com/#/zh-cn/ios/ios_doc/ios_sdk_init_access?id=_6-%e9%9a%90%e7%a7%81%e6%95%b0%e6%8d%ae%e8%af%b4%e6%98%8e
  854. *
  855. * Android 参见 https://docs.toponad.com/#/zh-cn/android/android_doc/android_sdk_init_access
  856. * @param deniedInfo Restricted privacy name
  857. */
  858. deniedUploadDeviceInfo(deniedInfo: string): void;
  859. /**
  860. * @en
  861. * Check the integration status of the advertising platform
  862. * @zh
  863. * 检查广告平台的集成状态
  864. */
  865. integrationChecking(): void;
  866. /**
  867. * @en
  868. * Get Banner ad object
  869. * @zh
  870. * 获取 Banner 广告对象
  871. * @param placementId placementId
  872. * @param listener Callback listener, if it is not passed, it must be displayed by calling the setAdListener method of the returned object, otherwise the advertisement callback will not be accepted
  873. * @returns Advertising target
  874. */
  875. getBanner(placementId: string, listener?: BannerListener): Banner;
  876. /**
  877. * @en
  878. * Get Interstitial ad object
  879. * @zh
  880. * 获取 Interstitial 广告对象
  881. * @param placementId placementId
  882. * @param listener Callback listener, if it is not passed, it must be displayed by calling the setAdListener method of the returned object, otherwise the advertisement callback will not be accepted
  883. * @returns Advertising target
  884. */
  885. getInterstitial(placementId: string, listener?: InterstitialListener): Interstitial;
  886. /**
  887. * @en
  888. * Get Native ad object
  889. * @zh
  890. * 获取 Native 广告对象
  891. * @param placementId placementId
  892. * @param listener Callback listener, if it is not passed, it must be displayed by calling the setAdListener method of the returned object, otherwise the advertisement callback will not be accepted
  893. * @returns Advertising target
  894. */
  895. getNative(placementId: string, listener?: NativeListener): Native;
  896. /**
  897. * @en
  898. * Get RewardVideo ad object
  899. * @zh
  900. * 获取 RewardVideo 广告对象
  901. * @param placementId placementId
  902. * @param listener Callback listener, if it is not passed, it must be displayed by calling the setAdListener method of the returned object, otherwise the advertisement callback will not be accepted
  903. * @returns Advertising target
  904. */
  905. getRewardVideo(placementId: string, listener?: RewardVideoListener): RewardVideo;
  906. }
  907. const toponService: TopOnAd;
  908. }