All Products
Document Center

Use the SDK

Last Updated: Aug 24, 2021

You can refer to the related code snippets to learn the usage of the framework and the MCDP component.

For the download address and usage method of the code example, refer to Obtain code sample. For API description, refer to API description.

Start the component

Start the MCDP component. After you start the App, you can call the start method to initialize and start the MCDP component.

The method is as follows:

  1. [CDPPromotionInterface start];
Note: We recommend that you add the code to the - (void)application:(UIApplication *)application beforeDidFinishLaunchingWithOptions:(NSDictionary *)launchOptions; method.

Configure the component

You can configure the MCDP SDK according to actual needs. For example, you can set the notification upon user’s logon and logout.

The method is as follows:

  1. // Configure the notification name upon a user's logon. This parameter has no default value.
  2. [CDPPromotionInterface sharedInstance].loginNotificationName = @"xxxx";
  3. // Configure the notification name a user's logout. This parameter has no default value.
  4. [CDPPromotionInterface sharedInstance].logoutNotificationName = @"xxxx";
  5. // Configure whether to use location information.
  6. [CDPPromotionInterface sharedInstance].useLbsInfo = YES;

Register the container plugin

When you place advertisements on HTML5 pages, you need to register the container plugin of the MCDP component.

Refer to Custom plug-in and register the container plugin used by the MCDP component as shown in the following figure.

Register container plugin

Report data sharing

This function allows you to report data sharing on the advertisement page. When a user completes sharing, the sharing action and related data is reported by calling the sharing reporting API. After this function is integrated, you can observe the corresponding data indicators on the dashboard of the console.

The procedure is as follows:

  1. Listen to the notification of tapping to share event.

    1. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(shareAd:) name:MPCDPDidShareAdNotification object:nil];
  2. Perform sharing in notification processing, and call the sharing reporting API after sharing is performed.
    1. - (void)shareAd:(NSNotification *)notification {
    2. NSString *adUrl = notification.object;
    3. // Initiate sharing
    4. // ...
    5. // Report advertisement sharing
    6. [[CDPPromotionInterface sharedInstance] reportShareAdAction];
    7. }