Paywall action interceptor

This feature replaces both Login and Purchase interceptor with a more generic approach.

Starting with v3.0, Purchasely allow you to intercept and override every paywall action.

This can be used to:

  • paywallObserver mode: intercept purchase and restore actions to perform them using your own code or another SDK

  • Intercept the login button tapped to display your login form

  • Force the explicit acceptance of terms and conditions before a purchase

  • Intercept the call to a webview to inject credentials and be directly logged in

  • Block promo codes in Kids category apps to add a parental permission gate

  • Block direct access to external content (webview or link to Safari) in Kids category apps to add a parental permission gate

With the action interceptor, you get everything you need to:

  • Get the action (and context)

  • Display views, errors, messages, … above our paywalls

  • Choose if Purchasely should continue the action or not

You can intercept the following buttons being tapped:

  • Close

  • Login

  • Navigate (web or deeplink)

  • Purchase

  • Restore

  • Open another paywall

  • Promo code

Implementation

The interceptor passes 4 parameters:

  1. action, the PLYPresentationAction enum that gives the type of action

  2. parameters, a dictionary that contains the objects needed to perform the action (like a PLYPlan for a purchase)

  3. info, the PLYPresentationInfo object containing the controller of the paywall to dismiss it or display content / error messages above it, and the presentation id and content id associated to this paywall

  4. proceed a completion handler parameter with a boolean telling Purchasely if it should continue the action itself.

    i.e. : Returning true on a purchase action will lead Purchasely to trigger the purchase

Purchasely.setPaywallActionsInterceptor { [weak self] (action, parameters, info, proceed) in

	switch action {
	
	// Intercept the tap on login
	case .login:
		// When the user has completed the process
		// Pass true to reload the paywall if user is logged in
		self?.presentLogin(above: info?.controller) { (loggedIn) in
			Purchasely.userLogin(with: "MY_USER_ID")
			proceed(loggedIn)
		}
	
	// Intercept the tap on purchase to display the terms and condition
	case .purchase:
		self?.presentTermsAndConditions(above: info?.controller) { (userAcceptedTerms) in
			proceed(userAcceptedTerms)
		}
	default:
		proceed(true)
		break
	}
}

Last updated

Was this helpful?