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()| Parameter | Type | Required | Description |
|---|---|---|---|
| Nil | Nil | Nil | This action does not require any parameter. |
Structure of Response
| Status | Response |
|---|---|
| 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
- Close after confirmation: Use closePopup after completing key actions like add-to-cart or form submission.
- Combine with UI actions: Pair it with showToast or showAlert for smoother user flows.
- Avoid premature closing: Ensure data or animations complete before closing.
- Graceful handling: Always check if a popup is active before closing (when possible).
- Consistent UX: Use automatic closures (e.g., 1–2 seconds) for success popups instead of forcing users to tap manually.
Caveats
- Active popup required: If no popup is currently open, this action has no visible effect.
- Limited scope: Only works for popups or modals opened within the Superfans app.
- No identifier targeting: The SDK closes the most recent popup — it doesn’t support targeting specific ones.
- Async behavior: Returns a Promise; handle completion for smoother UI transitions.
Updated about 1 month ago