APIs

This document details the APIs to enable Consent or Pay on your app or website.

Android

  1. To provide the login/subscription status to the CMP, use the following API with the appropriate value:

    Kotlin

    ChoiceCmp.setUserSubscriptionStatus(SUBSCRIPTION_STATE)
    

    Java

    ChoiceCmp.setUserSubscriptionStatus(SUBSCRIPTION_STATE);
    

     

    Note

    We recommend you use this API:

    • Just before initialising the SDK.
    • Once the login/subscription process is completed through the CMP. This enables the CMP to know the new status.
  2. The method onActionButtonClicked will be triggered when the user clicks any of the Action buttons. The parameter actionButton will contain the info about whether it’s ActionButton1 or ActionButton2.

    Kotlin

    override fun onActionButtonClicked(actionButton: ActionButton) {
       /* code */
    }
    

    Java

    @Override
    public void onActionButtonClicked(@NonNull ActionButton actionButton) {
        // code
    }
    

iOS

Note

Ensure consent or pay is enabled in the portal and applicable for the country. To know more about Consent or Pay, see Overview.

  1. To provide the login/subscription status to the CMP, use the following API with the appropriate value: 

    Objective-C

    [[ChoiceCmp shared] setUserLoginOrSubscriptionStatus:(BOOL)];
    

    Swift

    ChoiceCmp.shared.setUserLoginOrSubscriptionStatus(Bool)
    

     

    Note

    This API is recommended to be used:

    • Just before initialising the SDK (calling startChoice API).
    • Once the login/subscription process is completed through the CMP. This updates the status to the CMP.

    Objective-C

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        // Initialise InMobiCMP
        [[ChoiceCmp shared] setUserLoginOrSubscriptionStatus:true];
        [self startChoice];
        return YES;
    } 
    

    Swift

    @main
    class AppDelegate: UIResponder, UIApplicationDelegate, ChoiceCmpDelegate, CCPADelegate {
        func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
            ChoiceCmp.shared.setUserLoginOrSubscriptionStatus(true)
            ChoiceCmp.shared.startChoice(pcode: "< YOUR PCODE >", delegate: self)
            return true
        }
    } 
    
    

     

  2. Implement the following delegate function to receive the ActionButtons update.

    Objective-C

    (void) didReceiveActionButtonTapWithAction:(enum ActionButtons)action {  
      switch (action) { 
        case ActionButtonsAction1: 
        // Your implementation here.. 
        break;
        
        case ActionButtonsAction2: 
        // Your implementation here.. 
        break; 
        
        default:
        break; 
        } 
    } 
    

    Swift

    func didReceiveActionButtonTap(action: ActionButtons) {
      switch action {
        case .action1: 
        // Your implementation here..
        
        case .action2:
        // Your implementation here.. 
        } 
       } 
    
    
  3. The method didReceiveActionButtonTap will be triggered when the user clicks any of the Action buttons. The parameter actionButton will contain the info about whether it’s ActionButton1 or ActionButton2.

    Objective-C

    (void) didReceiveActionButtonTapWithAction:(enum ActionButtons)action {  
      switch (action) { 
        case ActionButtonsAction1: 
        // Your implementation here.. 
        break;
        
        case ActionButtonsAction2: 
        // Your implementation here.. 
        break; 
        
        default:
        break; 
        } 
    } 
    

    Swift

    func didReceiveActionButtonTap(action: ActionButtons) {
      switch action {
        case .action1: 
        // Your implementation here..
        
        case .action2:
        // Your implementation here.. 
        } 
       } 
    

     

    Note

    If the user has consent or pay enabled, moves to more options screen, then rejects all the consents, and then saves and exits, it will be treated as action button 1 press, and the same delegate will be called with ActionButton value as action1.

Web

Signaling User Subscription Status to the CMP

To indicate whether the user is subscribed, the publisher can set a JavaScript variable in the global window object. This can be used by the Consent Management Platform (CMP) to determine whether or not to display the consent popup.

Method:

window.__user_status = 'subscribed';
  • If the user is subscribed, the CMP will detect this signal and will not display the consent popup.
  • Additionally, the CMP will automatically store the consent status as reject since the user has already made a subscription decision.

Workflow:

  1. The publisher sets window.__user_status = 'subscribed'; when a user is confirmed to be subscribed.
  2. The CMP reads this signal upon initialization.
  3. If the user is subscribed (i.e., window.__user_status === 'subscribed'), the CMP skips the consent popup display.
  4. The CMP registers the consent status as "reject" (no further consent required).

On This Page

Last Updated on: 22 Apr, 2025