All Products
Search
Document Center

Mobile Platform as a Service:API reference

Last Updated:Mar 29, 2022

This topic 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

/**
 * Cdp ad serving interface
 *
 */
public abstract class CdpAdvertisementService extends ExternalService {

    /**
     * Initialize all advertising information
     *
     * @param extInfo extended information
     * @param callBack callback
     */
    public abstract void initialized(Map<String, String> extInfo, IAdGetSpaceInfoCallBack callBack);

    /**
     * Query the booth through the booth ID, and asynchronous callback onSuccess (SpaceInfo spaceInfo) returns the query result.
     * If there is no local cache, the RPC query result will be called back once.
     * If there is a local cache and the update time is not up, the local query result will be called back once.
     * 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.
     * The onFail() interface will be called back only when the RPC fails.
     *
     * @param spaceCode booth ID, you need to apply to the platform
     * @param callback callback interface
     */
    public abstract void getSpaceInfoByCode(String spaceCode, IAdGetSingleSpaceInfoCallBack callback);

    /**
     * Query the booth through the booth ID, and asynchronous callback onSuccess (SpaceInfo spaceInfo) returns the query result.
     * If there is no local cache, the RPC query result will be called back once.
     * If there is a local cache and the update time has not arrived, the local query result will be called back once.
     * 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.
     * The onFail() interface will be called back only when the RPC fails.
     *
     * @param spaceCode booth ID, you need to apply to the platform
     * @param extInfo extended parameters
     * @param immediately only returns the RPC result
     * @param callback callback interface
     */
    public abstract void getSpaceInfoByCode(String spaceCode, Map<String, String> extInfo, boolean immediately, final IAdGetSingleSpaceInfoCallBack callback);

    /**
     * Batch query booths by booth ID list, asynchronous onSuccess(List<SpaceInfo> adSpaceInfo) returns the query results.
     * If there is no local cache, the RPC query result will be called back once.
     * If there is a local cache and it is not yet time to update, the local query result will be called back once.
     * 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.
     * The onFail(List<String> adSpaceCodes) interface will be called back only when the RPC failed.
     *
     * @param spaceCodeList booth ID list, you need to apply to the platform
     * @param extInfo extended parameters
     * @param immediately only returns the RPC result
     * @param callback callback interface
     */
    public abstract void batchGetSpaceInfoByCode(List<String> spaceCodeList, Map<String, String> extInfo, boolean immediately, final IAdGetSpaceInfoCallBack callback);

    /**
     * H5 interface
     * Query and display ads, currently only called by AdH5Plugin
     *
     * @param activity current page
     * @param parentView parent control
     * @param url address
     * @param h5Param parameter
     */
    public abstract void checkAndShowAdInH5(final Activity activity, ViewGroup parentView, String url, String h5Param);

    /**
     * Remove the ad view with specified spaceCode
     *
     * @param activity Pages whose announcement need to be removed
     * @param spaceCode advertising ID
     */
    public abstract void removeAdvertisement(Activity activity, String spaceCode);

    /**
     * Get the action executor, return null if it is not set
     *
     * @return action executor
     */
    public abstract ActionExecutor getActionExecutor();

    /**
     * Set the action executor
     *
     * @param executor action executor
     */
    public abstract void setActionExecutor(ActionExecutor executor);


    /**
     * Set user ID
     *
     * @param userId user ID
     */
    public abstract void setUserId(String userId);

    /**
     * Get user ID
     *
     * @return user ID
     */
    public abstract String getUserId();

    /**
     * Get the callback class of the advertising booth
     */
    public interface IAdGetSpaceInfoCallBack {
        /**
         * Successfully obtained booth information
         *
         * @param adSpaceInfo booth list
         */
        void onSuccess(List<SpaceInfo> adSpaceInfo);

        /**
         * Failed to obtain booth information
         *
         * @param adSpaceCodes Code list of booth request
         */
        void onFail(List<String> adSpaceCodes);
    }

    /**
     * Get the callback class of a booth
     */
    public interface IAdGetSingleSpaceInfoCallBack {
        /**
         * Successfully obtained booth information
         *
         * @param spaceInfo Booth information
         */
        void onSuccess(SpaceInfo spaceInfo);

        /**
         * failed
         */
        void onFail();
    }
}

ActionExecutor

/**
 * Action processor
 *
 */
public interface ActionExecutor {

    /**
     * Whether to intercept Action
     * @param spaceInfo Booth information
     * @param spaceObjectInfo Advertising information
     * @param url action url
     * @return Return true for successful execution, false for exception
     */
    boolean interceptAction(final SpaceInfo spaceInfo, final SpaceObjectInfo spaceObjectInfo, final String url);

    /**
     * Execute Action
     *
     * @param spaceInfo Booth information
     * @param spaceObjectInfo Advertising information
     * @param url action url
     * @return Return 1 for successful execution, other values for exception
     */
    int executeAction(final SpaceInfo spaceInfo, final SpaceObjectInfo spaceObjectInfo, final String url);
}

Refresh

     /**
     * Refresh all status callback
     *
     */

   public interface IRefreshZoneCallBack{
        /**
         * Start
         *
         */
        void onStart();

        /**
         * End
         */
        void onEnd();
    }

  /**
     * Re-request ads when the user changes region, user id, etc.
     * @since 3.0
     * @param callBack
     */
   public abstract void refresh(IRefreshZoneCallBack callBack);