# Lottie animations

Lightweight, vectorial with a huge community, [Lottie](https://lottiefiles.com) has become the leading technology to create animations in applications.

From now on you can add Lottie animations in Purchasely paywalls but it requires a little setup from your mobile developers.

{% hint style="info" %}
This Lottie option is being added template by template. Don't hesitate to contact support to request a specific addition where you need it.
{% endhint %}

### Why is there any setup?

At Purchasely we value having a lightweight SDK (< 2Mb) with no external dependencies.

Thus, when we wanted to offer Lottie animations we didn't want to add it as a direct dependency of our SDK. This would have multiplied by 5 the weight of our SDK and users who didn't use it would have had to have to pay that extra cost.

This is how we ended up doing a weak dependency.

### How does it work?

At runtime, our SDKs will be looking at Lottie's presence and will add the view to its paywall. It will be able to configure the aspect (fill / fit) and wether or not the animation repeats.

As Purchasely SDK will be calling methods it needed a stable interface to avoid calling a method that wouldn't exist (and crash). This is why we created an interface to Lottie that will remain stable and will embed calls to Lottie framework so that we don't need to rely on them.

You will need to add this interface to your code and Lottie SDK in your dependencies.

## Configuration

### iOS

1. First you need to [add the Lottie dependency](https://github.com/airbnb/lottie-ios#installing-lottie) (if not already in your app)
2. Then add the following Swift class to your code

{% file src="<https://2145676854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKuAJGBnHJWZbqzA4g8yO%2Fuploads%2Fps9zvof1bMI3TSmxvX5S%2FPLYLottieBridge.swift?alt=media&token=21434c33-f412-45d8-ac1d-c9dbb78572ad>" %}

**🎉 You are all set!**

### Android

{% hint style="warning" %}
Lottie integration requires our SDK version 3.6.0 minimum
{% endhint %}

* First you need to [add the Lottie dependency](http://airbnb.io/lottie/#/android) (if not already in your app)
* Then implements `PLYLottieInterface`, you can copy the following sample `AnimationView` class
* Finally add it to Purchasely with

  ```
  Purchasely.lottieView = { AnimationView(context) }
  ```

{% file src="<https://2145676854-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKuAJGBnHJWZbqzA4g8yO%2Fuploads%2FhiKFQaj3y7aFkK429FrI%2FAnimationView.kt?alt=media&token=c5b3a915-fabf-4e04-9206-4026690e99b8>" %}
