Skip to content

Commit

Permalink
Merge branch 'SK2-clean' into develop
Browse files Browse the repository at this point in the history
* SK2-clean:
  Polished version for dev review
  • Loading branch information
Lutik-sun committed Nov 20, 2024
2 parents eddfaa2 + 0e17a16 commit a0bc15a
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 13 deletions.
6 changes: 6 additions & 0 deletions versioned_docs/version-3.0/flutter-handling-events-legacy.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import 'react-medium-image-zoom/dist/styles.css';

Paywalls configured with the [Paywall Builder](adapty-paywall-builder) don't need extra code to make and restore purchases. However, they generate some events that your app can respond to. Those events include button presses (close buttons, URLs, product selections, and so on) as well as notifications on purchase-related actions taken on the paywall. Learn how to respond to these events below.

:::warning

This guide is for **legacy Paywall Builder paywalls** only which require Adapty SDK up to v2.x. For presenting paywalls in Adapty SDK v3.0 or later designed with the new Paywall Builder, see [Flutter - Handle paywall events designed with the new Paywall Builder](flutter-handling-events).

:::

To control or monitor processes occurring on the paywall screen within your mobile app, implement the `AdaptyUIObserver` methods and register the observer before presenting any screen:

```javascript title="Flutter"
Expand Down
6 changes: 6 additions & 0 deletions versioned_docs/version-3.0/flutter-handling-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ metadataTitle: ""

Paywalls configured with the [Paywall Builder](adapty-paywall-builder-legacy) don't need extra code to make and restore purchases. However, they generate some events that your app can respond to. Those events include button presses (close buttons, URLs, product selections, and so on) as well as notifications on purchase-related actions taken on the paywall. Learn how to respond to these events below.

:::warning

This guide is for **new Paywall Builder paywalls** only which require Adapty SDK v3.0 or later. For presenting paywalls in Adapty SDK v2 designed with legacy Paywall Builder, see [Flutter - Handle paywall events designed with legacy Paywall Builder](flutter-handling-events-legacy).

:::

To control or monitor processes occurring on the paywall screen within your mobile app, implement the `AdaptyUIObserver` methods and register the observer before presenting any screen:

```javascript title="Flutter"
Expand Down
32 changes: 32 additions & 0 deletions versioned_docs/version-3.0/flutter-present-paywalls-legacy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: "Flutter - Present new Paywall Builder paywalls"
description: ""
metadataTitle: ""
---

import Zoom from 'react-medium-image-zoom';
import 'react-medium-image-zoom/dist/styles.css';

If you've customized a paywall using the Paywall Builder, you don't need to worry about rendering it in your mobile app code to display it to the user. Such a paywall contains both what should be shown within the paywall and how it should be shown.

:::warning

This guide is for **legacy Paywall Builder paywalls**, which require Adapty SDK up to version 2.x. The process for presenting paywalls differs for paywalls designed with different versions of Paywall Builder and remote config paywalls.

- For presenting **New Paywall Builder paywalls**, check out [Flutter - Present new Paywall Builder paywalls](flutter-present-paywalls).
- For presenting **Remote config paywalls**, see [Render paywall designed by remote config](present-remote-config-paywalls).

.
:::

To show a paywall, call `view.present()` method. You can use `view` from the previous step, we will introduce a new one for visibility reasons:

```typescript title="Flutter"
try {
await view.present();
} on AdaptyError catch (e) {
// handle the error
} catch (e) {
// handle the error
}
```
6 changes: 4 additions & 2 deletions versioned_docs/version-3.0/flutter-present-paywalls.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ If you've customized a paywall using the Paywall Builder, you don't need to worr

:::warning

This guide is for **legacy Paywall Builder paywalls**, which require Adapty SDK up to version 2.x. The [new Paywall Builder](adapty-paywall-builder) requires Adapty SDK 3.0 or later, which is currently not available for Flutter.
This guide is for **new Paywall Builder paywalls** only which require SDK v3.2.0 or later. The process for presenting paywalls differs for paywalls designed with different versions of Paywall Builde and remote config paywalls.

- For presenting **Legacy Paywall Builder paywalls**, check out [Flutter - Present legacy Paywall Builder paywalls](flutter-present-paywalls-legacy).
- For presenting **Remote config paywalls**, see [Render paywall designed by remote config](present-remote-config-paywalls).

For presenting remote config paywalls, see [Render paywall designed by remote config](present-remote-config-paywalls).
:::

To show a paywall, call `view.present()` method. You can use `view` from the previous step, we will introduce a new one for visibility reasons:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ While Paywall Builder seamlessly handles the purchasing process upon clicking "b
In native iOS and Android SDKs, you have complete control over both presenting and hiding the paywalls. However in Flutter, React Native, and Unity SDKs this works a bit differently. Learn how below.

:::warning
This guide covers only hiding **new Paywall Builder paywalls** which requires Adapty SDK v3.0 or later. To learn how to hide **legacy Paywall Builder paywalls**, read the [Hide legacy Paywall Builder paywalls (on cross-platform SDKs)](hide-legacy-paywall-builder-paywalls)
This guide covers only hiding **new Paywall Builder paywalls** which require Adapty SDK v3.0 (v3.2.0 for Flutter) or later. To learn how to hide **legacy Paywall Builder paywalls**, read the [Hide legacy Paywall Builder paywalls (on cross-platform SDKs)](hide-legacy-paywall-builder-paywalls)
:::

## Dismiss a paywall screen in React Native
Expand Down
29 changes: 27 additions & 2 deletions versioned_docs/version-3.0/ios-present-paywalls.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ If you've customized a paywall using the Paywall Builder, you don't need to worr

:::warning

This guide is for **new Paywall Builder paywalls** only which require SDK v3.0. The process for presenting paywalls differs for paywalls designed with different versions of Paywall Builde, remote config paywalls, and [Observer mode](observer-vs-full-mode).
This guide is for **new Paywall Builder paywalls** only which require SDK v3.0 or later. The process for presenting paywalls differs for paywalls designed with different versions of Paywall Builde, remote config paywalls, and [Observer mode](observer-vs-full-mode).

- For presenting **Legacy Paywall Builder paywalls**, check out [iOS - Present legacy Paywall Builder paywalls](ios-present-paywalls-legacy).
- For presenting **Remote config paywalls**, see [Render paywall designed by remote config](present-remote-config-paywalls).
Expand Down Expand Up @@ -116,4 +116,29 @@ Closure parameters:
| **didFailRestore** | If Adapty.restorePurchases() fails, this callback will be invoked. |
| **didFailRendering** | If an error occurs during the interface rendering, this callback will be invoked. |

Refer to the [iOS - Handling events](ios-handling-events) topic for other closure parameters.
Refer to the [iOS - Handling events](ios-handling-events) topic for other closure parameters.

## Use developer-defined timers

To use custom timers in your mobile app, create a `timerResolver` object—a dictionary or map that pairs custom timers with the string values that will replace them when the paywall is rendered. Here's an example:

```Swift
@MainActor
struct AdaptyTimerResolverImpl: AdaptyTimerResolver {
func timerEndAtDate(for timerId: String) -> Date {
switch timerId {
case "CUSTOM_TIMER_6H":
Date(timeIntervalSinceNow: 3600.0 * 6.0) // 6 hours
case "CUSTOM_TIMER_NY":
Calendar.current.date(from: DateComponents(year: 2025, month: 1, day: 1)) ?? Date(timeIntervalSinceNow: 3600.0)
default:
Date(timeIntervalSinceNow: 3600.0) // 1 hour
}
}
}
```

In this example, `CUSTOM_TIMER_NY` and `CUSTOM_TIMER_6H` are the IDs of custom timers you set in the Adapty Dashboard. The `timerResolver` ensures your app dynamically updates each timer with the correct value—for example:

- `CUSTOM_TIMER_NY`: The time remaining until the timer’s end, such as New Year’s Day.
- `CUSTOM_TIMER_6H`: The time left in a 6-hour period that started when the user opened the paywall.
28 changes: 21 additions & 7 deletions versioned_docs/version-3.0/react-native-present-paywalls.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: "React Native - Present new Paywall Builder paywalls"
description: ""
metadataTitle: ""

---

import Zoom from 'react-medium-image-zoom';
Expand All @@ -11,7 +12,7 @@ If you've customized a paywall using the Paywall Builder, you don't need to worr

:::warning

This guide is for **new Paywall Builder paywalls** only which require SDK v3.0. The process for presenting paywalls differs for paywalls designed with different versions of Paywall Builder and remote config paywalls.
This guide is for **new Paywall Builder paywalls** only which require SDK v3.0 or later. The process for presenting paywalls differs for paywalls designed with different versions of Paywall Builder and remote config paywalls.

- For presenting **legacy Paywall Builder paywalls**, check out [React Native - Present Paywall Builder paywalls](react-native-present-paywalls-legacy).
- For presenting **remote config paywalls**, see [Render paywall designed by remote config](present-remote-config-paywalls).
Expand All @@ -21,16 +22,29 @@ This guide is for **new Paywall Builder paywalls** only which require SDK v3.0.
To display a paywall view, simply call the `view.present()` method. If you've already defined a `view` object in a previous step, feel free to use it. In the following snippet, we'll introduce a new `view` for better visibility.

```typescript title="React Native (TSX)"
1
import {createPaywallView} from '@adapty/react-native-ui';

2
3
const view = await createPaywallView(paywall);

4
5
view.registerEventHandlers(); // handle close press, etc

6
7
try {
await view.present();
8
 await view.present();
9
} catch (error) {
// handle the error
10
 // handle the error
11
}

12
typescript title="React Native (TSX)"
```
2 changes: 1 addition & 1 deletion versioned_sidebars/version-3.0-sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@
},
{
"type": "doc",
"id": "flutter-present-paywalls",
"id": "flutter-present-paywalls-legacy",
"label": "Flutter"
},
{
Expand Down

0 comments on commit a0bc15a

Please sign in to comment.