import { NativeEventEmitter, EmitterSubscription } from 'react-native'; import type { ActiveProduct, BillingStatus, BuyOptions, EventName, Product, GetProductsOptions, Products, RestoreResponse, Transaction, ShowManageSubscriptionsOptions, StartOptions } from './types'; export default class Iaphub { nativeEventEmitter: NativeEventEmitter; errorListener?: EmitterSubscription; listeners: EmitterSubscription[]; constructor(); /** * Add event listener * @param name Native event emitted by the SDK. * @param callback Handler invoked with the event payload. */ addEventListener(name: EventName, callback: (data: any) => void): EmitterSubscription; /** * Remove event listener * @param listener Subscription returned by `addEventListener`. */ removeEventListener(listener: EmitterSubscription): boolean; /** * Remove all listeners */ removeAllListeners(): void; /** * Start Iaphub * @param opts Overall configuration object. * @param opts.appId IAPHUB app ID from the IAPHUB dashboard. * @param opts.apiKey IAPHUB Client API key from the IAPHUB dashboard. * @param opts.userId Optional user ID associated with the authenticated account. * @param opts.allowAnonymousPurchase Whether anonymous purchases are permitted; defaults to `false`. * @param opts.enableDeferredPurchaseListener Toggles the deferred purchase listener; defaults to `true`. * @param opts.enableStorekitV2 Enables StoreKit V2 when available (iOS 15+); defaults to `false` but enabling it is recommended. * @param opts.lang Locale code to localize product titles and descriptions defined on the IAPHUB dashboard (defaults to `en`). * @param opts.environment Target Iaphub environment; defaults to `production`. * @returns {Promise} */ start(opts: StartOptions): Promise; /** * Stop Iaphub * @returns {Promise} */ stop(): Promise; /** * Set lang * @param {String} lang Locale code (for example `en` or `fr`). * @returns {Promise} */ setLang(lang: string): Promise; /** * Log in user * @param {String} userId Unique identifier of the user. * @returns {Promise} */ login(userId: string): Promise; /** * Get user id * @returns {Promise} */ getUserId(): Promise; /** * Log out user * @returns {Promise} */ logout(): Promise; /** * Set device params * @param {Dict} params Key/value pairs with additional device metadata. * @returns {Promise} */ setDeviceParams(params: { [key: string]: any; }): Promise; /** * Set user tags * @param {Dict} tags Key/value pairs describing the user. * @returns {Promise} */ setUserTags(tags: { [key: string]: any; }): Promise; /** * Buy product * @param {String} sku Store identifier to purchase. * @param opts Purchase configuration (`crossPlatformConflict` defaults to `true`). * @param opts.crossPlatformConflict Throws an error if the user already has a subscription on a different platform; defaults to `true`. * @param opts.prorationMode Optional Google Play proration mode to apply when upgrading or downgrading. * @returns {Promise} */ buy(sku: string, opts?: BuyOptions): Promise; /** * Restore purchases * @returns {Promise} */ restore(): Promise; /** * Get active products * @param opts Optional filters (default `includeSubscriptionStates` is an empty array, meaning only active and grace period subscriptions are returned). * @returns {Promise} */ getActiveProducts(opts?: GetProductsOptions): Promise; /** * Get products for sale * @returns {Promise} */ getProductsForSale(): Promise; /** * Get products (active and for sale) * @param opts Optional filters (default `includeSubscriptionStates` is an empty array). * @param opts.includeSubscriptionStates List of subscription states to include in addition to `active` and `grace_period`. * @returns {Promise} */ getProducts(opts?: GetProductsOptions): Promise; /** * Get billing status * @returns {Promise} */ getBillingStatus(): Promise; /** * Present code redemption (iOS only) * @returns {Promise} */ presentCodeRedemptionSheet(): Promise; /** * Show manage subscriptions page * @param opts Optional parameters such as the SKU to highlight. * @param opts.sku SKU to highlight when opening the native page. * @returns {Promise} */ showManageSubscriptions(opts?: ShowManageSubscriptionsOptions): Promise; }