All Products
Search
Document Center

API reference

Last Updated: Aug 24, 2021

This article explains the APIs that involved in the access of Mobile Content Delivery Platform (MCDP).

  • CdpAdvertisementService: The CdpAdvertisementService in the middle layer of mPaaS encapsulates the interfaces of the MCDP. The related MCDP functions can be realized by calling these interfaces.
  • ActionExecutor: This interface implements the interception of booth and advertisement information. When intercepted, the client will not display the corresponding booths and advertisement contents; when not intercepted, the booths and advertisement contents will be displayed.
  • Refresh: Implement global status update. Used to re-request ads in scenarios where users change regions, user IDs, etc.

CdpAdvertisementService

  1. /**
  2. * Cdp ad serving interface
  3. *
  4. */
  5. public abstract class CdpAdvertisementService extends ExternalService {
  6. /**
  7. * Initialize all advertising information
  8. *
  9. * @param extInfo extended information
  10. * @param callBack callback
  11. */
  12. public abstract void initialized(Map<String, String> extInfo, IAdGetSpaceInfoCallBack callBack);
  13. /**
  14. * Query the booth through the booth ID, and asynchronous callback onSuccess (SpaceInfo spaceInfo) returns the query result.
  15. * If there is no local cache, the RPC query result will be called back once.
  16. * If there is a local cache and the update time is not up, the local query result will be called back once.
  17. * If there is a local cache and the update time is up, the local query result will be called back once, and the updated result will be called back again after the RPC is completed.
  18. * The onFail() interface will be called back only when the RPC fails.
  19. *
  20. * @param spaceCode booth ID, you need to apply to the platform
  21. * @param callback callback interface
  22. */
  23. public abstract void getSpaceInfoByCode(String spaceCode, IAdGetSingleSpaceInfoCallBack callback);
  24. /**
  25. * Query the booth through the booth ID, and asynchronous callback onSuccess (SpaceInfo spaceInfo) returns the query result.
  26. * If there is no local cache, the RPC query result will be called back once.
  27. * If there is a local cache and the update time has not arrived, the local query result will be called back once.
  28. * If there is a local cache and the update time is up, the local query result will be called back once, and the updated result will be called back again after the RPC is completed.
  29. * The onFail() interface will be called back only when the RPC fails.
  30. *
  31. * @param spaceCode booth ID, you need to apply to the platform
  32. * @param extInfo extended parameters
  33. * @param immediately only returns the RPC result
  34. * @param callback callback interface
  35. */
  36. public abstract void getSpaceInfoByCode(String spaceCode, Map<String, String> extInfo, boolean immediately, final IAdGetSingleSpaceInfoCallBack callback);
  37. /**
  38. * Batch query booths by booth ID list, asynchronous onSuccess(List<SpaceInfo> adSpaceInfo) returns the query results.
  39. * If there is no local cache, the RPC query result will be called back once.
  40. * If there is a local cache and it is not yet time to update, the local query result will be called back once.
  41. * If there is a local cache and it is time to update, the local query result will be called back once, and the updated result will be called back again after the RPC is completed.
  42. * The onFail(List<String> adSpaceCodes) interface will be called back only when the RPC failed.
  43. *
  44. * @param spaceCodeList booth ID list, you need to apply to the platform
  45. * @param extInfo extended parameters
  46. * @param immediately only returns the RPC result
  47. * @param callback callback interface
  48. */
  49. public abstract void batchGetSpaceInfoByCode(List<String> spaceCodeList, Map<String, String> extInfo, boolean immediately, final IAdGetSpaceInfoCallBack callback);
  50. /**
  51. * H5 interface
  52. * Query and display ads, currently only called by AdH5Plugin
  53. *
  54. * @param activity current page
  55. * @param parentView parent control
  56. * @param url address
  57. * @param h5Param parameter
  58. */
  59. public abstract void checkAndShowAdInH5(final Activity activity, ViewGroup parentView, String url, String h5Param);
  60. /**
  61. * Remove the ad view with specified spaceCode
  62. *
  63. * @param activity Pages whose announcement need to be removed
  64. * @param spaceCode advertising ID
  65. */
  66. public abstract void removeAdvertisement(Activity activity, String spaceCode);
  67. /**
  68. * Get the action executor, return null if it is not set
  69. *
  70. * @return action executor
  71. */
  72. public abstract ActionExecutor getActionExecutor();
  73. /**
  74. * Set the action executor
  75. *
  76. * @param executor action executor
  77. */
  78. public abstract void setActionExecutor(ActionExecutor executor);
  79. /**
  80. * Set user ID
  81. *
  82. * @param userId user ID
  83. */
  84. public abstract void setUserId(String userId);
  85. /**
  86. * Get user ID
  87. *
  88. * @return user ID
  89. */
  90. public abstract String getUserId();
  91. /**
  92. * Get the callback class of the advertising booth
  93. */
  94. public interface IAdGetSpaceInfoCallBack {
  95. /**
  96. * Successfully obtained booth information
  97. *
  98. * @param adSpaceInfo booth list
  99. */
  100. void onSuccess(List<SpaceInfo> adSpaceInfo);
  101. /**
  102. * Failed to obtain booth information
  103. *
  104. * @param adSpaceCodes Code list of booth request
  105. */
  106. void onFail(List<String> adSpaceCodes);
  107. }
  108. /**
  109. * Get the callback class of a booth
  110. */
  111. public interface IAdGetSingleSpaceInfoCallBack {
  112. /**
  113. * Successfully obtained booth information
  114. *
  115. * @param spaceInfo Booth information
  116. */
  117. void onSuccess(SpaceInfo spaceInfo);
  118. /**
  119. * failed
  120. */
  121. void onFail();
  122. }
  123. }

ActionExecutor

  1. /**
  2. * Action processor
  3. *
  4. */
  5. public interface ActionExecutor {
  6. /**
  7. * Whether to intercept Action
  8. * @param spaceInfo Booth information
  9. * @param spaceObjectInfo Advertising information
  10. * @param url action url
  11. * @return Return true for successful execution, false for exception
  12. */
  13. boolean interceptAction(final SpaceInfo spaceInfo, final SpaceObjectInfo spaceObjectInfo, final String url);
  14. /**
  15. * Execute Action
  16. *
  17. * @param spaceInfo Booth information
  18. * @param spaceObjectInfo Advertising information
  19. * @param url action url
  20. * @return Return 1 for successful execution, other values for exception
  21. */
  22. int executeAction(final SpaceInfo spaceInfo, final SpaceObjectInfo spaceObjectInfo, final String url);
  23. }

Refresh

  1. /**
  2. * Refresh all status callback
  3. *
  4. */
  5. public interface IRefreshZoneCallBack{
  6. /**
  7. * Start
  8. *
  9. */
  10. void onStart();
  11. /**
  12. * End
  13. */
  14. void onEnd();
  15. }
  16. /**
  17. * Re-request ads when the user changes region, user id, etc.
  18. * @since 3.0
  19. * @param callBack
  20. */
  21. public abstract void refresh(IRefreshZoneCallBack callBack);