Compare commits

..
Author SHA1 Message Date
Daniel Sogl 5599cce497 feat(in-app-purchase-2): add missing classic store API surface
Fills gaps against the last classic-API release of cordova-plugin-purchase
(v11.0.0) that this wrapper targets: new error codes, APPLICATION product
type, developerName property, product group/discount/countryCode/deferred
fields, and the getGroup() method and error(code, callback) overload.
2026-07-27 22:22:54 +02:00
2 changed files with 119 additions and 370 deletions
@@ -36,16 +36,6 @@ export interface AppsflyerOptions {
* time for the sdk to wait before launch - IOS 14 ONLY!
*/
waitForATTUserAuthorization?: number;
/**
* For iOS only, to test uninstall in Sandbox environment
*/
useUninstallSandbox?: boolean;
/**
* Prevents the SDK from sending the launch request after calling initSdk(...). When using this property, the app needs to manually trigger the startSdk() API to report the app launch. default=true
*/
shouldStartSdk?: boolean;
}
export interface AppsflyerEvent {
@@ -60,87 +50,6 @@ export interface AppsflyerInviteOptions {
};
}
export interface AppsflyerConsent {
/**
* Indicates whether GDPR regulations apply to the user. Also serves as a flag for compliance with relevant aspects of DMA regulations.
*/
isUserSubjectToGDPR: boolean | null;
/**
* Indicates whether the user has consented to use their data for advertising purposes.
*/
hasConsentForDataUsage: boolean | null;
/**
* Indicates whether the user has consented to use their data for personalized advertising.
*/
hasConsentForAdsPersonalization: boolean | null;
/**
* Indicates whether the user has provided consent for the storage of their advertising data.
*/
hasConsentForAdStorage: boolean | null;
}
export interface AppsflyerPurchaseDetails {
/**
* The purchase type: "subscription" or "one_time_purchase"
*/
purchaseType: string;
/**
* The purchase token from Google Play Store (Android) or transaction ID (iOS)
*/
purchaseToken: string;
/**
* The product identifier
*/
productId: string;
}
/**
* Mediation network values accepted by logAdRevenue's AppsflyerAdRevenueData.mediationNetwork field.
*/
export enum AppsflyerMediationNetwork {
IRONSOURCE = 'ironsource',
APPLOVIN_MAX = 'applovinmax',
GOOGLE_ADMOB = 'googleadmob',
FYBER = 'fyber',
APPODEAL = 'appodeal',
ADMOST = 'Admost',
TOPON = 'Topon',
TRADPLUS = 'Tradplus',
YANDEX = 'Yandex',
CHARTBOOST = 'chartboost',
UNITY = 'Unity',
TOPON_PTE = 'toponpte',
CUSTOM_MEDIATION = 'customMediation',
DIRECT_MONETIZATION_NETWORK = 'directMonetizationNetwork',
}
export interface AppsflyerAdRevenueData {
/**
* The monetization network name
*/
monetizationNetwork: string;
/**
* The mediation network used
*/
mediationNetwork: AppsflyerMediationNetwork;
/**
* ISO 4217 currency code
*/
currencyIso4217Code: string;
/**
* The ad revenue amount
*/
revenue: number;
}
/**
* @name Appsflyer
* @description
@@ -162,9 +71,6 @@ export interface AppsflyerAdRevenueData {
* AppsflyerOptions
* AppsflyerEvent
* AppsflyerInviteOptions
* AppsflyerConsent
* AppsflyerPurchaseDetails
* AppsflyerAdRevenueData
*/
@Plugin({
pluginName: 'Appsflyer',
@@ -303,276 +209,4 @@ export class Appsflyer extends AwesomeCordovaNativePlugin {
*/
@Cordova({ sync: true })
logCrossPromotionAndOpenStore(appId: string, campaign: string, options: object): void {}
/**
* Starts the SDK. Must call initSdk first in order to make this work. Used together with the AppsflyerOptions.shouldStartSdk option.
*/
@Cordova({ sync: true })
startSdk(): void {}
/**
* Register Unified deep link listener. Must be called before initSdk() and it overrides registerOnAppOpenAttribution.
*
* @returns {Promise<any>}
*/
@Cordova()
registerDeepLink(): Promise<any> {
return;
}
/**
* Set the currency code used for in-app purchase events.
*
* @param {string} currencyId ISO 4217 Currency Codes, default 'USD'
*/
@Cordova({ sync: true })
setCurrencyCode(currencyId: string): void {}
/**
* Get the current SDK version
*
* @returns {Promise<any>}
*/
@Cordova()
getSdkVersion(): Promise<any> {
return;
}
/**
* @deprecated deprecated since 6.4.0. Use setSharingFilterForPartners instead
* Used by advertisers to exclude all networks/integrated partners from getting data
*/
@Cordova({ sync: true })
setSharingFilterForAllPartners(): void {}
/**
* @deprecated deprecated since 6.4.0. Use setSharingFilterForPartners instead
* Used by advertisers to exclude specified networks/integrated partners from getting data
*
* @param {string[]} networks Array of partners that need to be excluded
*/
@Cordova({ sync: true })
setSharingFilter(networks: string[]): void {}
/**
* Used by advertisers to exclude specified networks/integrated partners from getting data
*
* @param {string[]} networks Array of partners that need to be excluded
*/
@Cordova({ sync: true })
setSharingFilterForPartners(networks: string[]): void {}
/**
* @deprecated Will be removed in the future. Please use validateAndLogInAppPurchaseV2.
* Receipt validation is a secure mechanism whereby the payment platform (e.g. Apple or Google) validates that an in-app purchase indeed occurred as reported.
*
* @param {AppsflyerEvent} purchaseInfo In-App Purchase parameters
* @returns {Promise<any>}
*/
@Cordova()
validateAndLogInAppPurchase(purchaseInfo: AppsflyerEvent): Promise<any> {
return;
}
/**
* Receipt validation is a secure mechanism whereby the payment platform (e.g. Apple or Google) validates that an in-app purchase indeed occurred as reported. This method uses V2 API.
*
* @param {AppsflyerPurchaseDetails} purchaseDetails Purchase details object containing productId, purchaseToken and purchaseType
* @param {AppsflyerEvent} additionalParameters Additional parameters to include with the purchase event (optional)
* @returns {Promise<any>}
*/
@Cordova()
validateAndLogInAppPurchaseV2(
purchaseDetails: AppsflyerPurchaseDetails,
additionalParameters?: AppsflyerEvent
): Promise<any> {
return;
}
/**
* In app purchase receipt validation Apple environment (production or sandbox)
*
* @param {boolean} isSandbox true if In app purchase is done with sandbox
* @returns {Promise<any>}
*/
@Cordova()
setUseReceiptValidationSandbox(isSandbox: boolean): Promise<any> {
return;
}
/**
* (iOS only) AppsFlyer SDK dynamically loads the Apple iAd.framework. This framework is required to record and measure the performance of Apple Search Ads in your app. If you don't want AppsFlyer to dynamically load this framework, set this property to true.
*
* @param {boolean} collectASA If you don't want AppsFlyer to dynamically load iAd.framework, set this property to true
* @returns {Promise<any>}
*/
@Cordova()
disableCollectASA(collectASA: boolean): Promise<any> {
return;
}
/**
* Disable collection of Apple, Google, Amazon and Open advertising ids (IDFA, GAID, AAID, OAID).
*
* @param {boolean} disableAdvertisingIdentifier Disable collection of advertising ids
* @returns {Promise<any>}
*/
@Cordova()
setDisableAdvertisingIdentifier(disableAdvertisingIdentifier: boolean): Promise<any> {
return;
}
/**
* Set Onelink custom/branded domains. Use this API during the SDK Initialization to indicate branded domains.
*
* @param {string[]} domains String array of branded domains
* @returns {Promise<any>}
*/
@Cordova()
setOneLinkCustomDomains(domains: string[]): Promise<any> {
return;
}
/**
* Support deferred deep linking from Facebook Ads. Use this API before initSdk().
*
* @param {boolean} isEnabled enable support deferred deep linking from Facebook Ads
*/
@Cordova({ sync: true })
enableFacebookDeferredApplinks(isEnabled: boolean): void {}
/**
* Set user emails for FB Advanced Matching
*
* @param {string[]} emails String array of emails
* @returns {Promise<any>}
*/
@Cordova()
setUserEmails(emails: string[]): Promise<any> {
return;
}
/**
* Set phone number for FB Advanced Matching
*
* @param {string} phoneNumber String phone number
* @returns {Promise<any>}
*/
@Cordova()
setPhoneNumber(phoneNumber: string): Promise<any> {
return;
}
/**
* Set custom host prefix and host name
*
* @param {string} hostPrefix host prefix
* @param {string} hostName host name
*/
@Cordova({ sync: true })
setHost(hostPrefix: string, hostName: string): void {}
/**
* Provides app owners with a flexible interface for configuring how deep links are extracted from push notification payloads. Must be called before initSdk().
*
* @param {string[]} path strings array of the path
*/
@Cordova({ sync: true })
addPushNotificationDeepLinkPath(path: string[]): void {}
/**
* Use this API to get the OneLink from click domains that launch the app. Make sure to call this API before SDK initialization.
*
* @param {string[]} urls strings array of domains
*/
@Cordova({ sync: true })
setResolveDeepLinkURLs(urls: string[]): void {}
/**
* Enable or disable SKAD support. Set true if you want to disable it. Must be called before initSdk() and for iOS only.
*
* @param {boolean} isDisabled disable or enable SKAD support
*/
@Cordova({ sync: true })
disableSKAD(isDisabled: boolean): void {}
/**
* Set the language of the device. The data will be displayed in Raw Data Reports. Must be called before initSdk() and for iOS only.
*
* @param {string} language The device language
*/
@Cordova({ sync: true })
setCurrentDeviceLanguage(language: string): void {}
/**
* Allows you to add custom data to events sent from the SDK. Typically used to integrate on the SDK level with several external partner platforms.
*
* @param {AppsflyerEvent} additionalData custom data
*/
@Cordova({ sync: true })
setAdditionalData(additionalData: AppsflyerEvent): void {}
/**
* Allows sending custom data for partner integration purposes.
*
* @param {string} partnerId ID of the partner (usually suffixed with "_int")
* @param {AppsflyerEvent} data Customer data, depends on the integration configuration with the specific partner
*/
@Cordova({ sync: true })
setPartnerData(partnerId: string, data: AppsflyerEvent): void {}
/**
* Measure and get data from push-notification campaigns.
*
* @param {AppsflyerEvent} pushData JSON object contains the push data
*/
@Cordova({ sync: true })
sendPushNotificationData(pushData: AppsflyerEvent): void {}
/**
* Use to opt-out of collecting the network operator name (carrier) and sim operator name from the device.
*
* @param {boolean} disable Defaults to false
*/
@Cordova({ sync: true })
setDisableNetworkData(disable: boolean): void {}
/**
* Set consent fields manually (e.g. by prompting user and collecting results). Use this API to provide the consent data directly to the SDK when GDPR applies to the user and your app does not use a CMP compatible with TCF v2.2.
*
* @param {AppsflyerConsent} appsFlyerConsent Consent data
*/
@Cordova({ sync: true })
setConsentData(appsFlyerConsent: AppsflyerConsent): void {}
/**
* Instruct the SDK to collect the TCF data from the device.
*
* @param {boolean} enable enable/disable TCF data collection
*/
@Cordova({ sync: true })
enableTCFDataCollection(enable: boolean): void {}
/**
* Log ad revenue event.
*
* @param {AppsflyerAdRevenueData} adRevenueData the ad revenue data
* @param {AppsflyerEvent} additionalParameters additional params data (optional)
*/
@Cordova({ sync: true })
logAdRevenue(adRevenueData: AppsflyerAdRevenueData, additionalParameters?: AppsflyerEvent): void {}
/**
* (Android only) Disables App Set ID collection (enabled by default).
*/
@Cordova({ sync: true })
disableAppSetId(): void {}
/**
* (iOS) Log deep linking. Add a function 'handleOpenUrl' to your root and call this to track deeplinks with AppsFlyer attribution data.
*
* @param {string} url the opened url
*/
@Cordova({ sync: true })
handleOpenUrl(url: string): void {}
}
@@ -5,6 +5,12 @@ export interface IAPProductOptions {
id: string;
alias?: string;
type: string;
/**
* Name of the group your subscription product is a member of (default to "default").
*
* If you don't set anything, all subscription will be members of the same group.
*/
group?: string;
}
export interface IRefeshResult {
@@ -31,6 +37,29 @@ export type IAPProducts = IAPProduct[] & {
export type IAPQueryCallback = ((product: IAPProduct) => void) | ((error: IAPError) => void);
export interface IAPProductDiscount {
/** The discount identifier */
id: string;
/** Localized price, with currency symbol */
price: string;
/** Price in micro-units (divide by 1000000 to get numeric price) */
priceMicros: number;
/** Number of subscription periods */
period: number;
/** Unit of the subcription period ("Day", "Week", "Month" or "Year") */
periodUnit: string;
/** "PayAsYouGo", "UpFront", or "FreeTrial" */
paymentMode: string;
/** True if the user is deemed eligible for this discount by the platform */
eligible: boolean;
}
export interface IAPProduct {
id: string;
@@ -38,6 +67,11 @@ export interface IAPProduct {
type: string;
/**
* Name of the group your subscription product is a member of (default to "default").
*/
group?: string;
state: string;
title: string;
@@ -50,6 +84,9 @@ export interface IAPProduct {
currency: string;
/** Country code. Available only on iOS */
countryCode?: string;
loaded: boolean;
valid: boolean;
@@ -58,6 +95,9 @@ export interface IAPProduct {
owned: boolean;
/** Purchase has been initiated but is waiting for external action (for example, Ask to Buy on iOS) */
deferred?: boolean;
downloading?: boolean;
downloaded?: boolean;
@@ -74,10 +114,19 @@ export interface IAPProduct {
introPriceSubscriptionPeriod?: string;
/** Duration the introductory price is available (in period-unit) */
introPricePeriod?: string;
/** Period for the introductory price ("Day", "Week", "Month" or "Year") */
introPricePeriodUnit?: string;
introPricePaymentMode?: string;
ineligibleForIntroPrice?: boolean;
/** Array of discounts available for the product. */
discounts?: IAPProductDiscount[];
billingPeriod?: number;
billingPeriodUnit?: string;
@@ -563,6 +612,7 @@ export class IAPError {
* IAPProduct
* IAPProductOptions
* IAPProductEvents
* IAPProductDiscount
* ```
*/
@Plugin({
@@ -594,7 +644,7 @@ export class InAppPurchase2 extends AwesomeCordovaNativePlugin {
* Debug level. Use QUIET, ERROR, WARNING, INFO or DEBUG constants
*/
@CordovaProperty()
verbosity: number;
verbosity: number | boolean;
/**
* Set to true to clear the transaction queue. Not recommended for production.
@@ -616,6 +666,14 @@ export class InAppPurchase2 extends AwesomeCordovaNativePlugin {
@CordovaProperty()
disableHostedContent: boolean;
/**
* An optional string of developer profile name. This value can be used for payment risk evaluation.
*
* Do not use the user account ID for this field.
*/
@CordovaProperty()
developerName: string;
@CordovaProperty()
FREE_SUBSCRIPTION: string;
@@ -631,6 +689,10 @@ export class InAppPurchase2 extends AwesomeCordovaNativePlugin {
@CordovaProperty()
NON_CONSUMABLE: string;
/** Type: The application bundle */
@CordovaProperty()
APPLICATION: string;
@CordovaProperty()
ERR_SETUP: number;
@@ -694,6 +756,46 @@ export class InAppPurchase2 extends AwesomeCordovaNativePlugin {
@CordovaProperty()
ERR_SUBSCRIPTION_UPDATE_NOT_AVAILABLE: number;
/** Error: The requested product is not available in the store. */
@CordovaProperty()
ERR_PRODUCT_NOT_AVAILABLE: number;
/** Error: The user has not allowed access to Cloud service information */
@CordovaProperty()
ERR_CLOUD_SERVICE_PERMISSION_DENIED: number;
/** Error: The device could not connect to the network. */
@CordovaProperty()
ERR_CLOUD_SERVICE_NETWORK_CONNECTION_FAILED: number;
/** Error: The user has revoked permission to use this cloud service. */
@CordovaProperty()
ERR_CLOUD_SERVICE_REVOKED: number;
/** Error: The user has not yet acknowledged Apple's privacy policy */
@CordovaProperty()
ERR_PRIVACY_ACKNOWLEDGEMENT_REQUIRED: number;
/** Error: The app is attempting to use a property for which it does not have the required entitlement. */
@CordovaProperty()
ERR_UNAUTHORIZED_REQUEST_DATA: number;
/** Error: The offer identifier is invalid. */
@CordovaProperty()
ERR_INVALID_OFFER_IDENTIFIER: number;
/** Error: The price you specified in App Store Connect is no longer valid. */
@CordovaProperty()
ERR_INVALID_OFFER_PRICE: number;
/** Error: The signature in a payment discount is not valid. */
@CordovaProperty()
ERR_INVALID_SIGNATURE: number;
/** Error: Parameters are missing in a payment discount. */
@CordovaProperty()
ERR_MISSING_OFFER_PARAMS: number;
@CordovaProperty()
REGISTERED: string;
@@ -783,12 +885,25 @@ export class InAppPurchase2 extends AwesomeCordovaNativePlugin {
}
/**
* Register error handler
* Register error handler.
*
* @param onError {Function} function to call on error
* Can also be called with an error code as the first argument to only listen to a specific error code.
*
* @param onErrorOrErrorCode {Function | number} function to call on error, or an error code to filter on
* @param [onError] {Function} function to call on error, when the first argument is an error code
*/
@Cordova({ sync: true })
error(onError: Function): void {}
error(onErrorOrErrorCode: Function | number, onError?: (err: IAPError) => void): void {}
/**
* Return all products member of a given subscription group.
*
* @param groupId
*/
@Cordova({ sync: true })
getGroup(groupId: string): IAPProduct[] {
return;
}
/**
* Add or register a product