Implement Observer mode in Unity SDK

If you already have your own purchase infrastructure and aren’t ready to fully switch to Adapty, you can explore Observer mode. In its basic form, Observer Mode offers advanced analytics and seamless integration with attribution and analytics systems.

If this meets your needs, you only need to:

  1. Turn it on when configuring the Adapty SDK by setting the observerMode parameter to true. Follow the setup instructions for Unity.
  2. Report transactions from your existing purchase infrastructure to Adapty.

In SDK v4, you can also present Adapty-rendered flows and paywalls in Observer mode: when a user taps the purchase or restore button, the SDK hands the action over to your code so you can perform the purchase or restore yourself. See Present flows in Observer mode.

Observer mode setup

Turn on the Observer mode if you handle purchases and subscription status yourself and use Adapty for sending subscription events and analytics.

When running in Observer mode, Adapty SDK won’t close any transactions, so make sure you’re handling it.

In SDK 4.0, listener interfaces follow the C# I-prefix convention: implement IAdaptyEventListener instead of AdaptyEventListener. The methods are unchanged. See the migration guide.

using UnityEngine;
using AdaptySDK;

public class AdaptyListener : MonoBehaviour, AdaptyEventListener {
    void Start() {
        DontDestroyOnLoad(this.gameObject);
        Adapty.SetEventListener(this);

        var builder = new AdaptyConfiguration.Builder("YOUR_PUBLIC_SDK_KEY")
            .SetObserverMode(true); // Enable observer mode

        Adapty.Activate(builder.Build(), (error) => {
            if (error != null) {
                // handle the error
                return;
            }
        });
    }

    public void OnLoadLatestProfile(AdaptyProfile profile) { }
    public void OnInstallationDetailsSuccess(AdaptyInstallationDetails details) { }
    public void OnInstallationDetailsFail(AdaptyError error) { }
}

Parameters:

ParameterDescription
observerModeA boolean value that controls Observer mode. The default value is false.

Using Adapty paywalls in Observer Mode

If you also want to use Adapty’s paywalls and A/B testing features, you can — but it requires some extra setup in Observer mode. Here’s what you’ll need to do in addition to the steps above:

  1. Display paywalls as usual for remote config paywalls.
  2. Associate paywalls with purchase transactions.