import { Product } from './dto/Product'; import { PurchaseOptions } from './dto/PurchaseOptions'; import { PurchaseResult } from './dto/PurchaseResult'; import { Entitlement } from './dto/Entitlement'; import { Offerings } from './dto/Offerings'; import { IntroEligibility } from './dto/IntroEligibility'; import { User } from './dto/User'; import { RemoteConfig } from './dto/RemoteConfig'; import { RemoteConfigList } from './dto/RemoteConfigList'; import { AttributionProvider, UserPropertyKey } from './dto/enums'; import { UserProperties } from './dto/UserProperties'; import { EntitlementsUpdateListener } from './dto/EntitlementsUpdateListener'; import { DeferredPurchasesListener } from './dto/DeferredPurchasesListener'; import { PromoPurchasesListener } from './dto/PromoPurchasesListener'; import { SKProductDiscount } from './dto/storeProducts/SKProductDiscount'; import { PromotionalOffer } from './dto/PromotionalOffer'; export interface QonversionApi { /** * Call this function to sync the subscriber data with the first launch when Qonversion is implemented. */ syncHistoricalData(): void; /** * iOS only * Contact us before you start using this function * Call this function to sync purchases if you are using StoreKit2 and our SDK in Analytics mode. */ syncStoreKit2Purchases(): void; /** * iOS only. * Retrieve the promotional offer for the product if it exists. * Make sure to call this function before displaying product details to the user. * The generated signature for the promotional offer is valid for a single transaction. * If the purchase fails, you need to call this function again to obtain a new promotional offer signature. * Use this signature to complete the purchase through the purchase function, along with the purchase options object. * @param product - product you want to purchase. * @param discount - discount to create promotional offer signature. * @returns the promise with the PromotionalOffer. */ getPromotionalOffer(product: Product, discount: SKProductDiscount): Promise; /** * Make a purchase and validate it through server-to-server using Qonversion's Backend. * Returns a PurchaseResult containing the status, entitlements, and transaction details. * @param product product to purchase * @param options additional options for the purchase process. * @returns the promise with the purchase result * * @see [Making Purchases](https://documentation.qonversion.io/docs/making-purchases) */ purchase(product: Product, options?: PurchaseOptions): Promise; /** * Returns Qonversion products in association with Apple and Google Play Store Products. * * @returns the promise with Qonversion products */ products(): Promise>; /** * Return Qonversion Offerings Object. * * An offering is a group of products that you can offer to a user on a given paywall based on your business logic. * For example, you can offer one set of products on a paywall immediately after onboarding and another * set of products with discounts later on if a user has not converted. * Offerings allow changing the products offered remotely without releasing app updates. * * @returns the promise with Qonversion offerings * * @deprecated Offerings are deprecated. Manage paywall products with Remote Configs instead: https://documentation.qonversion.io/docs/migrate-offerings-to-remote-configs * * @see [Migrate Offerings to Remote Configs](https://documentation.qonversion.io/docs/migrate-offerings-to-remote-configs) for more details */ offerings(): Promise; /** * You can check if a user is eligible for an introductory offer, including a free trial. * You can show only a regular price for users who are not eligible for an introductory offer. * * @param ids products identifiers that must be checked * @returns the promise with eligibility map */ checkTrialIntroEligibility(ids: string[]): Promise>; /** * You need to call the checkEntitlements method to check if a user has the required entitlement. * * This method will check the user receipt and will return the current entitlements. * * @returns the promise with the entitlements * * If Apple or Google servers are not responding at the time of the request, Qonversion provides the latest * entitlements' data from its database. */ checkEntitlements(): Promise>; /** * Restores users purchases in your app, to maintain access to purchased content. * Users sometimes need to restore purchased content, such as when they upgrade to a new phone. * * @returns the promise with the user entitlements */ restore(): Promise>; /** * Android only. Does nothing if called on iOS. * * This method will send all purchases to the Qonversion backend. Call this every time when purchase is handled * by your own implementation. * * **Warning!** * * This method works for Android only. * It should only be called if you're using Qonversion SDK in observer mode. * * @see [Observer mode for Android SDK](https://documentation.qonversion.io/docs/observer-mode#android-sdk) */ syncPurchases(): void; /** * Call this function to link a user to his unique ID in your system and share purchase data. * * @param userId unique user ID in your system * @returns the promise with the information about the identified user. */ identify(userId: string): Promise; /** * Call this function to unlink a user from his unique ID in your system and his purchase data. */ logout(): void; /** * This method returns information about the current Qonversion user. * @returns the promise with the information about the user. */ userInfo(): Promise; /** * Returns Qonversion remote config object by {@link contextKey} or default one if the key is not specified. * Use this function to get the remote config with specific payload and experiment info. * @returns the promise with the remote config. */ remoteConfig(contextKey: string | undefined): Promise; /** * Returns Qonversion remote config objects for all existing context key (including empty one). * Use this function to get the remote config with specific payload and experiment info. * @returns the promise with the remote config list. */ remoteConfigList(): Promise; /** * Returns Qonversion remote config objects by a list of {@link contextKeys}. * Use this function to get the remote config with specific payload and experiment info. * @param contextKeys list of context keys to load remote configs for * @param includeEmptyContextKey set to true if you want to include remote config with empty context key to the result * @returns the promise with the remote config list. */ remoteConfigListForContextKeys(contextKeys: Array, includeEmptyContextKey: boolean): Promise; /** * Invalidates the cache of remote configs so the next {@link remoteConfig} or * {@link remoteConfigList} call fetches a fresh targeting evaluation from the * server instead of returning the cached copy. * * This method performs no network request itself — it only marks the cached * values as stale. An in-flight remoteConfig load is re-issued once so its * waiting calls receive a fresh evaluation; an in-flight remoteConfigList * completes with the evaluation it started with. * * Call it when the targeting inputs changed and you need the change reflected * immediately, for example after setting a batch of user properties your * remote config targeting depends on. You do NOT need to call it after * {@link identify} — the SDK invalidates the cache on identity changes * automatically. * * If the re-issued load fails, the previously received evaluation is * delivered instead of an error — the call never degrades below the * pre-invalidation result. * * Call it after {@link Qonversion.initialize}: calling before initialization * throws on Android and does nothing on iOS. */ invalidateRemoteConfigsCache(): void; /** * This function should be used for the test purposes only. Do not forget to delete the usage of this function before the release. * Use this function to attach the user to the experiment. * @param experimentId identifier of the experiment * @param groupId identifier of the experiment group * @returns the promise for success result or throws an error otherwise. */ attachUserToExperiment(experimentId: string, groupId: string): Promise; /** * This function should be used for the test purposes only. Do not forget to delete the usage of this function before the release. * Use this function to detach the user from the experiment. * @param experimentId identifier of the experiment * @returns the promise for success result or throws an error otherwise. */ detachUserFromExperiment(experimentId: string): Promise; /** * This function should be used for the test purposes only. Do not forget to delete the usage of this function before the release. * Use this function to attach the user to the remote configuration. * @param remoteConfigurationId identifier of the remote configuration * @returns the promise for success result or throws an error otherwise. */ attachUserToRemoteConfiguration(remoteConfigurationId: string): Promise; /** * This function should be used for the test purposes only. Do not forget to delete the usage of this function before the release. * Use this function to detach the user from the remote configuration. * @param remoteConfigurationId identifier of the remote configuration * @returns the promise for success result or throws an error otherwise. */ detachUserFromRemoteConfiguration(remoteConfigurationId: string): Promise; /** * Call this function to check if the fallback file is accessible. * @returns the promise with the flag that indicates whether Qonversion was able to read data from the fallback file or not. */ isFallbackFileAccessible(): Promise; /** * Sends your attribution {@link data} to the {@link provider}. * * @param data an object containing your attribution data * @param provider the provider to which the data will be sent */ attribution(data: Object, provider: AttributionProvider): void; /** * Sets Qonversion reserved user properties, like email or user id * * User properties are attributes you can set on a user level. * You can send user properties to third party platforms as well as use them in Qonversion for customer segmentation * and analytics. * * Note that using {@link UserPropertyKey.CUSTOM} here will do nothing. * To set custom user property, use {@link setCustomUserProperty} method instead. * * @param key defined enum key that will be transformed to string. * @param value property value. * * @see [documentation](https://documentation.qonversion.io/docs/user-properties) */ setUserProperty(key: UserPropertyKey, value: string): void; /** * Adds custom user property. * * User properties are attributes you can set on a user level. * You can send user properties to third party platforms as well as use them in Qonversion for customer segmentation * and analytics. * * @param key custom user property key. * @param value property value. * * @see [documentation](https://documentation.qonversion.io/docs/user-properties) */ setCustomUserProperty(key: string, value: string): void; /** * This method returns all the properties, set for the current Qonversion user. * All set properties are sent to the server with delay, so if you call * this function right after setting some property, it may not be included * in the result. * @returns the promise with the user properties */ userProperties(): Promise; /** * Force-flushes any pending user property updates to the server immediately. * Use this when you need to ensure all previously set properties have been sent * before performing an operation that depends on them. */ forceSendProperties(): Promise; /** * Provide a listener to be notified about asynchronous user entitlements updates. * * Make sure you provide this listener for being up-to-date with the user entitlements. * Else you can lose some important updates. Also, please, consider that this listener * should live for the whole lifetime of the application. * * You may set entitlements listener both *after* Qonversion SDK initializing * with {@link QonversionApi.setEntitlementsUpdateListener} and *while* Qonversion initializing * with {@link Qonversion.initialize}. * * @param listener listener to be called when entitlements update * @deprecated Use {@link QonversionApi.setDeferredPurchasesListener} instead, which provides detailed purchase result information for deferred purchase completions. */ setEntitlementsUpdateListener(listener: EntitlementsUpdateListener): void; /** * Provide a listener to be notified about deferred purchases (e.g., SCA, Ask to Buy) * once they are completed. * * You may set this listener *after* Qonversion SDK initialization using this method, * or *during* Qonversion initialization via {@link QonversionConfigBuilder.setDeferredPurchasesListener}. * * @param listener listener to be called when a deferred purchase completes. */ setDeferredPurchasesListener(listener: DeferredPurchasesListener): void; /** * iOS only. Does nothing if called on Android. * * On iOS 14.5+, after requesting the app tracking permission using ATT, you need to notify Qonversion if tracking * is allowed and IDFA is available. */ collectAdvertisingId(): void; /** * iOS only. Does nothing if called on Android. * * Enable attribution collection from Apple Search Ads. */ collectAppleSearchAdsAttribution(): void; /** * iOS only. Does nothing if called on Android. * * Set the delegate to handle promo purchases. * The delegate is called when a promo purchase from the App Store happens. * @param delegate delegate to be called when event happens. */ setPromoPurchasesDelegate(delegate: PromoPurchasesListener): void; /** * iOS only. Does nothing if called on Android. * * On iOS 14.0+ shows up a sheet for users to redeem App Store offer codes. */ presentCodeRedemptionSheet(): void; }