Migrate to SDK v3.0

Purchasely SDK v3.0 brings a lot of new amazing features:

It also removes the following:

Update start method

The start method changes:

  • the observerMode parameter is replaced by a more comprehensive runningMode

  • the confirmPurchaseHandler parameter is replaced by paywallActionsInterceptor

Grab new events and properties

Expect null controllers / fragments

Even if you don't use observer mode or new modes you will have to adapt your code

Some of the new modes block the display of the paywall. In that case the paywall is not returned. This is the reason why the following methods are not returning optionals:

  • productController

  • planController

  • presentationController

Migrate the Purchase interceptor

Purchase interceptor was used to trigger app specific code before triggering the purchase using Purchasely.

It could be used to display specific terms and conditions, present a parental gate or perform a purchase using your own code or a third party subscription tool.

If you are using Purchase interceptor you probably have some code like that:

Purchasely.setConfimPurchaseHandler { [weak self](paywallController, processToPayment) in
	// Display the terms of use to your user
	self?.presentTermsAndConditions(above: paywallController) { (userAcceptedTerms) in
		// Don't forget to notify the SDK by calling `processToPayment`
		processToPayment(userAcceptedTerms)
	}
}

it should be changed to something like that:

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

	switch action {

	// Intercept the tap on purchase to display the terms and condition
	case .purchase:
		self?.presentTermsAndConditions(above: presentationInfo?.controller) { (userAcceptedTerms) in
			proceed(userAcceptedTerms)
		}
	default:
		proceed(true)
		break
	}
}

If your are intercepting several actions (purchase, login, …) you must add a case and should only have one call to Purchasely.setPaywallActionsInterceptor

Migrate the Login interceptor

Every presentation, has an Already subscribed? Sign-in button to let your customers connect to unlock a feature / access a content.

To intercept the tap on this button you had to use the loginTappedHandler interceptor

Purchasely.setLoginTappedHandler { (paywallController, isLoggedIn) in
	// Get your login controller
	loginCtrl = LoginViewController()
	
	// Configure the response to notify Purchasely that it needs to reload (if needed)
	loginCtrl.configure(with: isLoggedIn)
	
	paywallController.present(loginCtrl, animated: true, completion: nil)
}

With SDK v3 this feature is moved to the paywall actions interceptor and your code should change to something like that:

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

	switch action {

	// Intercept the tap on login
	case .login:
		// When the user has completed the process
		// Pass true to reload the paywall or dismiss the paywall if the user already has an active subscription
		self?.presentLogin(above: presentationInfo?.controller) { (loggedIn) in
			proceed(loggedIn)
		}
	default:
		proceed(true)
		break
	}
}

If your are intercepting several action (purchase, login, …) you must add a case and should only have one call to Purchasely.setPaywallActionsInterceptor

Last updated

© Purchasely 2020-2023