Package com.adapty

Object Adapty

  • All Implemented Interfaces:

    
    public class Adapty
    
                        
    • Constructor Detail

    • Method Detail

      • activate

         final static Unit activate(Context context, String appKey, Boolean observerMode, String customerUserId)

        Use this method to initialize the Adapty SDK.

        Parameters:
        context - Application context.
        appKey - You can find it in your app settings in Adapty Dashboard App settings General.
        observerMode - A boolean value controlling Observer mode.
        customerUserId - User identifier in your system.
      • activate

         final static Unit activate(Context context, String appKey, Boolean observerMode)

        Use this method to initialize the Adapty SDK.

        Parameters:
        context - Application context.
        appKey - You can find it in your app settings in Adapty Dashboard App settings General.
        observerMode - A boolean value controlling Observer mode.
      • activate

         final static Unit activate(Context context, String appKey)

        Use this method to initialize the Adapty SDK.

        Parameters:
        context - Application context.
        appKey - You can find it in your app settings in Adapty Dashboard App settings General.
      • identify

         final static Unit identify(String customerUserId, ErrorCallback callback)

        Use this method for identifying user with it’s user id in your system.

        If you don’t have a user id on SDK configuration, you can set it later at any time with .identify() method. The most common cases are after registration/authorization when the user switches from being an anonymous user to an authenticated user.

        Should not be called before activate

        Parameters:
        customerUserId - User identifier in your system.
        callback - An result containing the optional AdaptyError.
      • getProfile

         final static Unit getProfile(ResultCallback<AdaptyProfile> callback)

        The main function for getting a user profile. Allows you to define the level of access, as well as other parameters.

        The getProfile method provides the most up-to-date result as it always tries to query the API. If for some reason (e.g. no internet connection), the Adapty SDK fails to retrieve information from the server, the data from cache will be returned. It is also important to note that the Adapty SDK updates AdaptyProfile cache on a regular basis, in order to keep this information as up-to-date as possible.

        Should not be called before activate

        Parameters:
        callback - A result containing the AdaptyProfile object.
      • getPaywall

         final static Unit getPaywall(String placementId, String locale, AdaptyPlacementFetchPolicy fetchPolicy, TimeInterval loadTimeout, ResultCallback<AdaptyPaywall> callback)

        Fetches the paywall by the specified placement.

        With Adapty, you can remotely configure the products and offers in your app by simply adding them to paywalls – no need for hardcoding them. The only thing you hardcode is the placement ID.

        This flexibility allows you to easily update paywalls, products, and offers, or run A/B tests, all without the need for a new app release.

        Should not be called before activate

        Parameters:
        placementId - The identifier of the desired placement.
        locale - This parameter is expected to be a language code composed of one or more subtags separated by the "-" character.
        fetchPolicy - By default SDK will try to load data from server and will return cached data in case of failure.
        loadTimeout - This value limits the timeout for this method.
        callback - A result containing the AdaptyPaywall object.
      • getPaywall

         final static Unit getPaywall(String placementId, String locale, AdaptyPlacementFetchPolicy fetchPolicy, ResultCallback<AdaptyPaywall> callback)

        Fetches the paywall by the specified placement.

        With Adapty, you can remotely configure the products and offers in your app by simply adding them to paywalls – no need for hardcoding them. The only thing you hardcode is the placement ID.

        This flexibility allows you to easily update paywalls, products, and offers, or run A/B tests, all without the need for a new app release.

        Should not be called before activate

        Parameters:
        placementId - The identifier of the desired placement.
        locale - This parameter is expected to be a language code composed of one or more subtags separated by the "-" character.
        fetchPolicy - By default SDK will try to load data from server and will return cached data in case of failure.
        callback - A result containing the AdaptyPaywall object.
      • getPaywall

         final static Unit getPaywall(String placementId, String locale, ResultCallback<AdaptyPaywall> callback)

        Fetches the paywall by the specified placement.

        With Adapty, you can remotely configure the products and offers in your app by simply adding them to paywalls – no need for hardcoding them. The only thing you hardcode is the placement ID.

        This flexibility allows you to easily update paywalls, products, and offers, or run A/B tests, all without the need for a new app release.

        Should not be called before activate

        Parameters:
        placementId - The identifier of the desired placement.
        locale - This parameter is expected to be a language code composed of one or more subtags separated by the "-" character.
        callback - A result containing the AdaptyPaywall object.
      • getPaywall

         final static Unit getPaywall(String placementId, ResultCallback<AdaptyPaywall> callback)

        Fetches the paywall by the specified placement.

        With Adapty, you can remotely configure the products and offers in your app by simply adding them to paywalls – no need for hardcoding them. The only thing you hardcode is the placement ID.

        This flexibility allows you to easily update paywalls, products, and offers, or run A/B tests, all without the need for a new app release.

        Should not be called before activate

        Parameters:
        placementId - The identifier of the desired placement.
        callback - A result containing the AdaptyPaywall object.
      • reportTransaction

         final static Unit reportTransaction(TransactionInfo transactionInfo, String variationId, ResultCallback<AdaptyProfile> callback)

        In Observer mode, Adapty SDK doesn’t know, where the purchase was made from. If you display products using our Paywalls or A/B Tests, you can manually assign variation to the purchase. After doing this, you’ll be able to see metrics in Adapty Dashboard.

        Should not be called before activate

        Parameters:
        transactionInfo - A TransactionInfo instance, containing either a string identifier (purchase.getOrderId()) of the purchase, or an instance of the billing library Purchase class.
        variationId - A string identifier of variation.
        callback - A result containing the optional AdaptyError.
      • reportTransaction

         final static Unit reportTransaction(TransactionInfo transactionInfo, ResultCallback<AdaptyProfile> callback)

        In Observer mode, Adapty SDK doesn’t know, where the purchase was made from. If you display products using our Paywalls or A/B Tests, you can manually assign variation to the purchase. After doing this, you’ll be able to see metrics in Adapty Dashboard.

        Should not be called before activate

        Parameters:
        transactionInfo - A TransactionInfo instance, containing either a string identifier (purchase.getOrderId()) of the purchase, or an instance of the billing library Purchase class.
        callback - A result containing the optional AdaptyError.
      • logout

         final static Unit logout(ErrorCallback callback)

        You can logout the user anytime by calling this method.

        Should not be called before activate

        Parameters:
        callback - A result containing the optional AdaptyError.
      • setLogHandler

         final static Unit setLogHandler(AdaptyLogHandler logHandler)

        Override the default logger behavior using this method.

        Can be called before activate

        Parameters:
        logHandler - The function will be called for each message with the appropriate logLevel (e.g.
      • setFallback

         final static Unit setFallback(FileLocation location, ErrorCallback callback)

        To set fallback paywalls, use this method. You should pass exactly the same payload you’re getting from Adapty backend. You can copy it from Adapty Dashboard.

        Adapty allows you to provide fallback paywalls that will be used when a user opens the app and there's no connection with Adapty backend (e.g. no internet connection or in the rare case when backend is down) and there's no cache on the device.

        Should not be called before activate

        Parameters:
        location - A location of a file with JSON representation of your paywalls/products list in the exact same format as provided by Adapty backend.
        callback - A result containing the optional AdaptyError.
      • setFallback

         final static Unit setFallback(FileLocation location)

        To set fallback paywalls, use this method. You should pass exactly the same payload you’re getting from Adapty backend. You can copy it from Adapty Dashboard.

        Adapty allows you to provide fallback paywalls that will be used when a user opens the app and there's no connection with Adapty backend (e.g. no internet connection or in the rare case when backend is down) and there's no cache on the device.

        Should not be called before activate

        Parameters:
        location - A location of a file with JSON representation of your paywalls/products list in the exact same format as provided by Adapty backend.
      • logShowPaywall

         final static Unit logShowPaywall(AdaptyPaywall paywall, ErrorCallback callback)

        Call this method to notify Adapty SDK, that particular paywall was shown to user.

        Adapty helps you to measure the performance of the paywalls. We automatically collect all the metrics related to purchases except for paywall views. This is because only you know when the paywall was shown to a customer.

        Whenever you show a paywall to your user, call .logShowPaywall(paywall) to log the event, and it will be accumulated in the paywall metrics.

        Should not be called before activate

        Parameters:
        paywall - A AdaptyPaywall object.
        callback - A result containing the optional AdaptyError.
      • logShowPaywall

         final static Unit logShowPaywall(AdaptyPaywall paywall)

        Call this method to notify Adapty SDK, that particular paywall was shown to user.

        Adapty helps you to measure the performance of the paywalls. We automatically collect all the metrics related to purchases except for paywall views. This is because only you know when the paywall was shown to a customer.

        Whenever you show a paywall to your user, call .logShowPaywall(paywall) to log the event, and it will be accumulated in the paywall metrics.

        Should not be called before activate

        Parameters:
        paywall - A AdaptyPaywall object.
      • logShowOnboarding

         final static Unit logShowOnboarding(String name, String screenName, @IntRange(from = 1) Integer screenOrder, ErrorCallback callback)

        Call this method to keep track of the user’s steps while onboarding.

        The onboarding stage is a very common situation in modern mobile apps. The quality of its implementation, content, and number of steps can have a rather significant influence on further user behavior, especially on his desire to become a subscriber or simply make some purchases.

        In order for you to be able to analyze user behavior at this critical stage without leaving Adapty, we have implemented the ability to send dedicated events every time a user visits yet another onboarding screen.

        Should not be called before activate

        Parameters:
        name - Name of your onboarding.
        screenName - Readable name of a particular screen as part of onboarding.
        screenOrder - An unsigned integer value representing the order of this screen in your onboarding sequence (it must me greater than 0).
        callback - A result containing the optional AdaptyError.
      • logShowOnboarding

         final static Unit logShowOnboarding(String name, String screenName, @IntRange(from = 1) Integer screenOrder)

        Call this method to keep track of the user’s steps while onboarding.

        The onboarding stage is a very common situation in modern mobile apps. The quality of its implementation, content, and number of steps can have a rather significant influence on further user behavior, especially on his desire to become a subscriber or simply make some purchases.

        In order for you to be able to analyze user behavior at this critical stage without leaving Adapty, we have implemented the ability to send dedicated events every time a user visits yet another onboarding screen.

        Should not be called before activate

        Parameters:
        name - Name of your onboarding.
        screenName - Readable name of a particular screen as part of onboarding.
        screenOrder - An unsigned integer value representing the order of this screen in your onboarding sequence (it must me greater than 0).
      • getPaywallForDefaultAudience

         final static Unit getPaywallForDefaultAudience(String placementId, String locale, AdaptyPlacementFetchPolicy fetchPolicy, ResultCallback<AdaptyPaywall> callback)

        Fetches the paywall of the specified placement for the All Users audience.

        With Adapty, you can remotely configure the products and offers in your app by simply adding them to paywalls – no need for hardcoding them. The only thing you hardcode is the placement ID.

        This flexibility allows you to easily update paywalls, products, and offers, or run A/B tests, all without the need for a new app release.

        However, it’s crucial to understand that the recommended approach is to fetch the paywall through the placement ID by the getPaywall method. The getPaywallForDefaultAudience method should be a last resort due to its significant drawbacks. See docs for more details

        Should not be called before activate

        Parameters:
        placementId - The identifier of the desired placement.
        locale - This parameter is expected to be a language code composed of one or more subtags separated by the "-" character.
        fetchPolicy - By default SDK will try to load data from server and will return cached data in case of failure.
        callback - A result containing the AdaptyPaywall object.
      • getPaywallForDefaultAudience

         final static Unit getPaywallForDefaultAudience(String placementId, String locale, ResultCallback<AdaptyPaywall> callback)

        Fetches the paywall of the specified placement for the All Users audience.

        With Adapty, you can remotely configure the products and offers in your app by simply adding them to paywalls – no need for hardcoding them. The only thing you hardcode is the placement ID.

        This flexibility allows you to easily update paywalls, products, and offers, or run A/B tests, all without the need for a new app release.

        However, it’s crucial to understand that the recommended approach is to fetch the paywall through the placement ID by the getPaywall method. The getPaywallForDefaultAudience method should be a last resort due to its significant drawbacks. See docs for more details

        Should not be called before activate

        Parameters:
        placementId - The identifier of the desired placement.
        locale - This parameter is expected to be a language code composed of one or more subtags separated by the "-" character.
        callback - A result containing the AdaptyPaywall object.
      • getPaywallForDefaultAudience

         final static Unit getPaywallForDefaultAudience(String placementId, ResultCallback<AdaptyPaywall> callback)

        Fetches the paywall of the specified placement for the All Users audience.

        With Adapty, you can remotely configure the products and offers in your app by simply adding them to paywalls – no need for hardcoding them. The only thing you hardcode is the placement ID.

        This flexibility allows you to easily update paywalls, products, and offers, or run A/B tests, all without the need for a new app release.

        However, it’s crucial to understand that the recommended approach is to fetch the paywall through the placement ID by the getPaywall method. The getPaywallForDefaultAudience method should be a last resort due to its significant drawbacks. See docs for more details

        Should not be called before activate

        Parameters:
        placementId - The identifier of the desired placement.
        callback - A result containing the AdaptyPaywall object.