Controling Screen visibility
This section describes how to close a Screen programmatically
Minimum SDK versionsThe lifecycle described here is the 6.0 display API.
- iOS: 6.0.0
- Android: 6.0.1
- Flutter: 6.0.0
- React Native: 6.0.0-rc.2
- Cordova: 6.0.0
There is nohideprimitive any moreIn v5,
hidePresentation()/showPresentation()/closePresentation()let you temporarily dismiss a Screen and bring it back. All three are removed in v6.
v5 v6 Purchasely.closeDisplayedPresentation()(iOS)Purchasely.closeAllScreens()Purchasely.hidePresentation()close()— then display again to bring the Screen backPurchasely.showPresentation()display()on the presentation handle or on the requestPurchasely.closePresentation()close()(kept as a deprecated alias on Cordova only)To show a Screen again after closing it, fetch it again with
preload. See the v5 → v6 migration guides.
Two different scopes
| Method | What it closes |
|---|---|
close() on a presentation | That presentation. Available on the loaded presentation handle. |
Purchasely.closeAllScreens() | Every Purchasely Screen currently displayed, whatever the display path. |
Use closeAllScreens() when you need a guaranteed clean slate — for example when your app navigates away, or after handling a purchase yourself in Observer mode, where presentations no longer auto-close.
Both produce a programmatic close reason in the presentation outcome.
Native iOS and Android
Call close() on the loaded presentation object.
PLYPresentationBuilder
.forPlacementId("onboarding")
.build()
.preload { presentation, error in
// once displayed, close this presentation
presentation?.close()
}
// Or, at any time, close every displayed Purchasely Screen
Purchasely.closeAllScreens()PLYPresentation {
placementId("onboarding")
}.preload { presentation, error ->
// once displayed, close this presentation
presentation?.close()
}
// Or, at any time, close every displayed Purchasely Screen
Purchasely.closeAllScreens()
back()is also availableOn the loaded presentation,
back()navigates to the previous step instead of dismissing — useful inside a Flow.
Flutter
The imperative global methods are gone. Use the loaded PLYPresentation handle, obtained from preload() or from outcome.presentation.
// Close this presentation
presentation.close();
// Display it (again) — after a close you must preload it first
presentation.display();React Native
Use the request returned by .build().
const request = Purchasely.presentation.placement('onboarding').build();
await request.display();
// Dismiss it
request.close();
request.close()does not have the same scope on both platforms
- iOS — closes the specific presentation identified by its
requestId, falling back to closing all Purchasely Screens when the request is no longer tracked.- Android — the native SDK does not expose a per-request close yet, so it dismisses all displayed presentations. If you stack presentations (for example a product page inside an onboarding Flow), closing one also dismisses the others.
The v5 top-level
close()is removed. UsePurchasely.closeAllScreens()when you explicitly want to dismiss everything.
Cordova
// Dismiss the presentation of this request
request.close();
// Or close every displayed Purchasely Screen
Purchasely.closeAllScreens();request.back() navigates back one step. On Cordova, request.close() always closes every displayed presentation, not only this request.
closePresentation()is a deprecated alias
closeAllScreensis the canonical name on Cordova.closePresentation()still works with identical behavior but is deprecated.showPresentation()andhidePresentation()were removed with no alias.
To learn more about fetching and displaying Screens, see displaying screens.
Updated 9 days ago

