Represents the specific reason why an entitlement was not granted when showing an offer. This includes both user-initiated actions (declining, dismissing) and system-initiated reasons (no offers available, errors).
Definition
public enum NotGrantedReason {
// User-initiated
case userTappedClose
case userSwipedDown
case userTappedOutside
case lastOfferDeclined
// System-initiated
case noOffersAvailable
case error(Error)
}
Cases
| Case | Type | Description |
|---|
.userTappedClose | User-initiated | User explicitly tapped X or “No Thanks” button |
.userSwipedDown | User-initiated | User swiped down to dismiss the modal |
.userTappedOutside | User-initiated | User tapped outside the modal area to dismiss |
.lastOfferDeclined | User-initiated | User declined all available offers |
.noOffersAvailable | System-initiated | No offers matched user criteria or campaign conditions |
.error(Error) | System-initiated | A system error occurred |
Usage
Simple Handling
Encore.placement()
.onNotGranted { reason in
// Just proceed with original action
proceedWithCancellation()
}
.show()
Detailed Handling
Encore.placement()
.onNotGranted { reason in
switch reason {
case .userTappedClose, .userSwipedDown, .userTappedOutside, .lastOfferDeclined:
analytics.track("user_dismissed_offer")
proceedWithCancellation()
case .noOffersAvailable:
analytics.track("no_offers_available")
proceedWithCancellation()
case .error(let error):
analytics.track("offer_error", error: error)
handleError(error)
proceedWithCancellation()
}
}
.show()
For most use cases, you can treat all cases the same way - just proceed with the user’s original action. Detailed handling is only needed for analytics or special business logic.