Skip to content

Commit

Permalink
Merge branch 'SK2-clean' into develop
Browse files Browse the repository at this point in the history
* SK2-clean:
  ios-present updated
  Update
  Minor changes
  • Loading branch information
Lutik-sun committed Nov 20, 2024
2 parents aa99ddc + 2db2112 commit 707ac6f
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 89 deletions.
160 changes: 81 additions & 79 deletions versioned_docs/version-3.0/ios-present-paywalls.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,90 +21,92 @@ This guide is for **new Paywall Builder paywalls** only which require SDK v3.0 o

## Present paywalls in Swift

In order to display the visual paywall on the device screen, you must first configure it. To do this, use the method `.paywallController(for:products:introductoryOffersEligibilities:viewConfiguration:delegate:)`:

```swift title="Swift"
import Adapty
import AdaptyUI

do {
let visualPaywall = try AdaptyUI.paywallController(
for: <paywall object>,
products: <paywall products array>,
introductoryOffersEligibilities: <intro offers eligibilities dictionary>,
viewConfiguration: <LocalizedViewConfiguration>,
delegate: <AdaptyPaywallControllerDelegate>
)
} catch {
// handle the error
}
```

Request parameters:

| Parameter | Presence | Description |
| :---------------------------------- | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Paywall** | required | An `AdaptyPaywall` object to obtain a controller for the desired paywall. |
| **Products** | optional | Provide an array of `AdaptyPaywallProducts` to optimize the display timing of products on the screen. If `nil` is passed, AdaptyUI will automatically fetch the necessary products. |
| **IntroductoryOffersEligibilities** | optional | Provide the dictionary of offers eligibilities to optimize the display timing of offers eligibilities on the screen. If `nil` is passed, AdaptyUI will automatically fetch the necessary offers eligibilities. |
| **ViewConfiguration** | required | An `AdaptyUI.LocalizedViewConfiguration` object containing visual details of the paywall. Use the `AdaptyUI.getViewConfiguration(paywall:locale:)` method. Refer to [Fetch Paywall Builder paywalls and their configuration](get-pb-paywalls) topic for more details. |
| **Delegate** | required | An `AdaptyPaywallControllerDelegate` to listen to paywall events. Refer to [Handling paywall events](ios-handling-events) topic for more details. |
| **TagResolver** | optional | Define a dictionary of custom tags and their resolved values. Custom tags serve as placeholders in the paywall content, dynamically replaced with specific strings for personalized content within the paywall. Refer to [Custom tags in paywall builder](custom-tags-in-paywall-builder) topic for more details. |
| **TimerResolver** | optional | Pass the resolver here if you are going to use custom timer functionality. |

Returns:

| Object | Description |
| :---------------------- | :--------------------------------------------------- |
| AdaptyPaywallController | An object, representing the requested paywall screen |

After the object has been successfully created, you can display it on the screen of the device:

```swift title="Swift"
present(visualPaywall, animated: true)
```
In order to display the visual paywall on the device screen, do the following:

1. Create a paywall configuration object:

```swift title="Swift"
do {
let paywallConfiguration = try AdaptyUI.getPaywallConfiguration(
forPaywall: <paywall object>
)
} catch {
// handle the error
}
```

Request parameters:

| Parameter | Presence | Description |
| :---------- | :------- | :----------------------------------------------------------- |
| **Paywall** | required | An `AdaptyPaywall` object to obtain a controller for the desired paywall. |

3. Initialize the visual paywall you want to display by using the `.paywallController(for:products:viewConfiguration:delegate:)` method:

```swift title="Swift"
import Adapty
import AdaptyUI

let visualPaywall = AdaptyUI.paywallController(
with: <paywall configuration object>,
delegate: <AdaptyPaywallControllerDelegate>
)
```

Request parameters:

| Parameter | Presence | Description |
| :----------------------- | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Paywall Configuration** | required | An `AdaptyUI.PaywallConfiguration` object containing visual details of the paywall. Use the `AdaptyUI.getPaywallConfiguration(forPaywall:locale:)` method. Refer to [Fetch Paywall Builder paywalls and their configuration](get-pb-paywalls) topic for more details. |
| **Delegate** | required | An `AdaptyPaywallControllerDelegate` to listen to paywall events. Refer to [Handling paywall events](ios-handling-events) topic for more details. |
Returns:

| Object | Description |
| :---------------------- | :--------------------------------------------------- |
| AdaptyPaywallController | An object, representing the requested paywall screen |

3. After the object has been successfully created, you can display it on the screen of the device:

```swift title="Swift"
present(visualPaywall, animated: true)
```

## Present paywalls in SwiftUI

In order to display the visual paywall on the device screen, use the `.paywall` modifier in SwiftUI:

```swift title="SwiftUI"
@State var paywallPresented = false

var body: some View {
Text("Hello, AdaptyUI!")
.paywall(
isPresented: $paywallPresented,
paywall: <paywall object>,
viewConfiguration: <LocalizedViewConfiguration>,
didPerformAction: { action in
switch action {
case .close:
paywallPresented = false
default:
// Handle other actions
break
}
},
didFinishPurchase: { product, profile in paywallPresented = false },
didFailPurchase: { product, error in /* handle the error */ },
didFinishRestore: { profile in /* check access level and dismiss */ },
didFailRestore: { error in /* handle the error */ },
didFailRendering: { error in paywallPresented = false }
)
}
```

Request parameters:

| Parameter | Presence | Description |
| :---------------------------------- | :------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Paywall** | required | An `AdaptyPaywall` object to obtain a controller for the desired paywall. |
| **Product** | optional | Provide an array of `AdaptyPaywallProducts` to optimize the display timing of products on the screen. If `nil` is passed, AdaptyUI will automatically fetch the necessary products. |
| **IntroductoryOffersEligibilities** | optional | Provide the dictionary of offers eligibilities to optimize the display timing of offers eligibilities on the screen. If `nil` is passed, AdaptyUI will automatically fetch the necessary offers eligibilities. |
| **Configuration** | required | An `AdaptyUI.LocalizedViewConfiguration` object containing visual details of the paywall. Use the `AdaptyUI.getViewConfiguration(paywall:locale:)` method. Refer to [Fetch Paywall Builder paywalls and their configuration](get-pb-paywalls) topic for more details. |
| **TagResolver** | optional | Define a dictionary of custom tags and their resolved values. Custom tags serve as placeholders in the paywall content, dynamically replaced with specific strings for personalized content within the paywall. Refer to [Custom tags in paywall builder](custom-tags-in-paywall-builder) topic for more details. |
| **TimerResolver** | optional | Pass the resolver here if you are going to use custom timer functionality. |

```swift title="SwiftUI"
@State var paywallPresented = false

var body: some View {
Text("Hello, AdaptyUI!")
.paywall(
isPresented: $paywallPresented,
- paywall: <paywall object>,
- configuration: <LocalizedViewConfiguration>,
- observerModeResolver: <AdaptyObserverModeResolver>,
+ paywallConfiguration: <paywall configuration object>,
didPerformAction: { action in
switch action {
case .close:
paywallPresented = false
default:
// Handle other actions
break
}
},
didFinishRestore: { profile in /* check access level and dismiss */ },
didFailRestore: { error in /* handle the error */ },
didFailRendering: { error in paywallPresented = false }
)
}
```
| Parameter | Presence | Description |
| :----------------------- | :------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Paywall Configuration** | required | An `AdaptyUI.PaywallConfiguration` object containing visual details of the paywall. Use the `AdaptyUI.getPaywallConfiguration(forPaywall:locale:)` method. Refer to [Fetch Paywall Builder paywalls and their configuration](get-pb-paywalls) topic for more details. |
| **Products** | optional | Provide an array of `AdaptyPaywallProducts` to optimize the display timing of products on the screen. If `nil` is passed, AdaptyUI will automatically fetch the necessary products. |
| **TagResolver** | optional | Define a dictionary of custom tags and their resolved values. Custom tags serve as placeholders in the paywall content, dynamically replaced with specific strings for personalized content within the paywall. Refer to [Custom tags in paywall builder](custom-tags-in-paywall-builder) topic for more details. |

Closure parameters:

Expand Down
35 changes: 27 additions & 8 deletions versioned_docs/version-3.0/migration-to-adapty-sdk-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,38 +194,56 @@ dependencies {

</TabItem>

<TabItem value="Flutter" label="Flutter" default>
<TabItem value="Flutter" label="For Flutter" default>

:::info

Please note that the AdaptyUI library is deprecated and is now included as part of AdaptySDK.

:::

## Remove AdaptyUI SDK

1. Since AdaptyUI is now a module in the Adapty SDK, remove `adapty_ui_flutter` from your `pubspec.yaml` file:
1. AdaptyUI becomes a module in SAdapty SDK, so please remove `adapty_ui_flutter` from your `pubspec.yaml` file:

```diff
dependencies:
adapty_flutter: ^3.2.0
- adapty_ui_flutter: ^2.1.3
```

2. Then run:
2. Run:

```bash title="Bash"
flutter pub get
```

3. Remove import of SDKs form your application:

```diff
- import 'package:adapty_flutter/adapty_flutter.dart';
- import 'package:adapty_ui_flutter/adapty_ui_flutter.dart';
```



## Configure Adapty SDKs

Previously, you needed to create an `Adapty-Info.plist` file and add it to your project for Adapty SDK configuration. Now, there’s no need for additional files. Instead, provide all the required parameters during activation.
Previously you created a Adapty-Info.plist file and added it to your project and then Adapty SDK configuration used theis file.

Now you do not nee to create additional files. Instead provide all required parameters during activation

You only need to configure the Adapty SDK once, typically early in your app's lifecycle.

### Activate Adapty module of Adapty SDK

1. Remove the import for the AdaptyUI SDK from your application, like this:
1. Import Adapty SDKs in your application in the following way:

```diff
```dart title="Dart"
import 'package:adapty_flutter/adapty_flutter.dart';
- import 'package:adapty_ui_flutter/adapty_ui_flutter.dart';
```

2. Add the Adapty SDK parameters like this:
2. Activate Adapty SDK with the following code:

```diff
try {
Expand All @@ -249,6 +267,7 @@ Parameters:
| ----------------------------------- | -------- | ------------------------------------------------------------ |
| **PUBLIC_SDK_KEY** | required | The key you can find in the **Public SDK key** field of your app settings in Adapty: [**App settings**-> **General** tab -> **API keys** subsection](https://app.adapty.io/settings/general) |
| **withLogLevel** | optional | Adapty logs errors and other crucial information to provide insight into your app's functionality. There are the following available levels:<ul><li> error: Only errors will be logged.</li><li> warn: Errors and messages from the SDK that do not cause critical errors, but are worth paying attention to will be logged.</li><li> info: Errors, warnings, and serious information messages, such as those that log the lifecycle of various modules will be logged.</li><li> verbose: Any additional information that may be useful during debugging, such as function calls, API queries, etc. will be logged.</li></ul> |
| **withObserverMode** | optional | <p>A boolean value controlling [Observer mode](observer-vs-full-mode). Turn it on if you handle purchases and subscription status yourself and use Adapty for sending subscription events and analytics.</p><p>The default value is `false`.</p><p></p><p>🚧 When running in Observer mode, Adapty SDK won't close any transactions, so make sure you're handling it.</p> |
| **withCustomerUserId** | optional | An identifier of the user in your system. We send it in subscription and analytical events, to attribute events to the right profile. You can also find customers by `customerUserId` in the [**Profiles and Segments**](https://app.adapty.io/profiles/users) menu. |
| **withIdfaCollectionDisabled** | optional | <p>Set to `true` to disable IDFA collection and sharing.</p><p>the user IP address sharing.</p><p>The default value is `false`.</p><p>For more details on IDFA collection, refer to the [Analytics integration](analytics-integration#disable-collection-of-idfa) section.</p> |
| **withIpAddressCollectionDisabled** | optional | <p>Set to `true` to disable user IP address collection and sharing.</p><p>The default value is `false`.</p> |
Expand Down
Loading

0 comments on commit 707ac6f

Please sign in to comment.