Close Popup

An event that will dismiss the popup.

Description

The closePopup action programmatically closes any currently open popup, modal, or overlay within the Superfans app.
It provides developers a simple way to dismiss UI elements like promotional popups, custom modals, or form overlays without requiring user interaction.

Function Signature

VajroSDK.actions.closePopup()
ParameterTypeRequiredDescription
NilNilNilThis action does not require any parameter.

Structure of Response

StatusResponse
Success{"status": "success", "message": "popup dismissed successfully" }
Unexpected Error{ "status": "error", "errorId": 500, "errorHandle": "unknown-error", "message": "Something unexpected happened" }

Example Usage

//Opens a custom block when app opened on phone 
VajroSDK.actions.openCustomBlock({
type:"popup_bottom",
id:"cbk_0mshe0349jy0g"
});


// Function to close the popup automatically after 5 seconds
function closePopupAfterDelay() {
    setTimeout(() => {
        VajroSDK.actions.closePopup();
    }, 5000); // 3000 milliseconds = 3 seconds
}

// Call the function to initiate the delay
closePopupAfterDelay();

Best Practices

  1. Close after confirmation: Use closePopup after completing key actions like add-to-cart or form submission.
  2. Combine with UI actions: Pair it with showToast or showAlert for smoother user flows.
  3. Avoid premature closing: Ensure data or animations complete before closing.
  4. Graceful handling: Always check if a popup is active before closing (when possible).
  5. Consistent UX: Use automatic closures (e.g., 1–2 seconds) for success popups instead of forcing users to tap manually.

Caveats

  1. Active popup required: If no popup is currently open, this action has no visible effect.
  2. Limited scope: Only works for popups or modals opened within the Superfans app.
  3. No identifier targeting: The SDK closes the most recent popup — it doesn’t support targeting specific ones.
  4. Async behavior: Returns a Promise; handle completion for smoother UI transitions.