How to use your own paywall within Purchasely environment.
The feature described in this section is supported on the following versions and above:
iOS: 3.5.0
Android: 3.5.0
ReactNative: 2.5.0
Cordova: 2.5.0
Flutter: 1.5.0
It could sound weird to use your home made paywall in a No Code paywall environment but it is indeed very useful to:
A/A test your paywall against the same one implemented using Purchasely's template
Test your existing paywall against one of our No Code paywall and run tests to beat your reference
Easily deploy price A/B testing infrastructure without changing your UI
Implementation
The basic paywall implementation directly returns a piece of UI but to be able to make both your paywall alongside with Purchasely's paywalls you will need to proceed differently.
First, you must declare your own paywall in our console along with the plans you wish to offer on your paywall if you want to do price A/B tests
Then you will need to fetch the paywalls and therefore you won't be able to directly display a screen returned by Purchasely.
You will have to first fetch the paywall then check whether you should display your own paywall or display the provided paywall.\
Then call clientPresentationDisplayed(presentation) when your paywall is displayed and clientPresentationClosed(presentation) when your paywall is closed.
These steps are mandatory for Purchasely to compute conversion on your paywall and measure the performance of A/B tests.
// Call when your paywall is displayed// in ViewDidAppear for examplePurchasely.clientPresentationOpened(with: presentation)// Call when your paywall has been closed// in viewWillDisappear for examplePurchasely.clientPresentationClosed(with: presentation)// Call clientPresentationClosed in Purchasely.syncPurchase() closure // if you are in paywallObserverMode
// Call when your paywall is displayed
// in ViewDidAppear for example
[Purchasely clientPresentationOpenedWith:presentation];
// Call when your paywall has been closed
// in viewWillDisappear for example
[Purchasely clientPresentationClosedWith:presentation];
// Call when your paywall is displayed// For example in the onCreate() method of your ActivityPurchasely.clientPresentationDisplayed(presentation)// Call when your paywall is closed// For example in the onDestroy() method of your ActivityPurchasely.clientPresentationClosed(presentation)
// Call when your paywall is displayed// For example in the onCreate() method of your ActivityPurchasely.clientPresentationDisplayed(presentation);// Call when your paywall is closed// For example in the onDestroy() method of your ActivityPurchasely.clientPresentationClosed(presentation);
// Call when your paywall is displayedPurchasely.clientPresentationDisplayed(presentation);// Call when your paywall is closedPurchasely.clientPresentationClosed(presentation);
// Call when your paywall is displayedPurchasely.clientPresentationDisplayed(presentation);// Call when your paywall is closedPurchasely.clientPresentationClosed(presentation);
You can of course start the purchase from your own paywall with Purchasely by using Purchasely.purchase(plan), more information here
Metadata
Available starting with SDK 4.1.0
You can declare your metadata with Your Own Paywall which can be:
String (but you can set different types with it, look at example code below)
Image
Boolean
These steps are mandatory for Purchasely to compute conversion on your paywall and measure the performance of A/B tests.
// Documentation coming soon// Look at Kotlin example as it is the same methods
Purchasely.fetchPresentationForPlacement(this, "onboarding") { presentation, error ->if(error !=null) { Log.d("Purchasely", "Error fetching paywall", error)return@fetchPresentationForPlacement }if(presentation?.type == PLYPresentationType.CLIENT) {val paywallId = presentation.idval plans = presentation.plansval metadata = presentation.metadata// Get string metadata, this method is asynchronous as it will parse tagsval myString = metadata.getString("myString", callback = { Log.d("Demo", "myString: $it") })// You can also use coroutine scope.launch {val myString = metadata.getString("myString") }// If you do not use Purchasely tagsval myString2 = metadata.getStringWithoutTags("myString2")val myBoolean = metadata.getBoolean("myBoolean")// Even if declared as a String in our console, // Purchasely SDK will automatically try to convert to specific type // For example: "4.7" is a double or floatval myInt = metadata.getInt("myInt")val myLong = metadata.getLong("myLong")val myFloat = metadata.getFloat("myFloat")val myDouble = metadata.getDouble("myDouble")// If you set a metadata with a String ISO 8601, you can retrieve the date// "2023-09-21T09:48:25Z"val myDate = metadata.getDate("myDate")// or Instantval myDateAsInstant =if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { metadata.getInstant("myDate") } elsenull// If you set a medata with a String which is a json, you can retrieve it// "{"name":"Stranger","int_value":4,"child":{"title":"Things"}}"val myJson = metadata.getJsonObject("myJson") }}
// Release coming soon
// Release coming soon
You can of course do the purchase transaction from your own paywall with Purchasely by using Purchasely.purchase(plan), more information here