Skip to main content
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

CaseTypeDescription
.userTappedCloseUser-initiatedUser explicitly tapped X or “No Thanks” button
.userSwipedDownUser-initiatedUser swiped down to dismiss the modal
.userTappedOutsideUser-initiatedUser tapped outside the modal area to dismiss
.lastOfferDeclinedUser-initiatedUser declined all available offers
.noOffersAvailableSystem-initiatedNo offers matched user criteria or campaign conditions
.error(Error)System-initiatedA 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.