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 125 additions and 199 deletions
@@ -3,27 +3,10 @@ import { AwesomeCordovaNativePlugin, Cordova, Plugin } from '@awesome-cordova-pl
import { Observable } from 'rxjs';
export interface InitializeConfig {
/**
* @deprecated Never populated by the native SDKs. Use `hasUserConsent` instead.
*/
hasUserConsentValue?: boolean;
/**
* @deprecated Never populated by the native SDKs, and the underlying `isAgeRestrictedUser`
* field was removed upstream in cordova-plugin-applovin-max@2.0.0.
*/
isAgeRestrictedUserValue?: boolean;
/**
* @deprecated Never populated by the native SDKs. Use `isDoNotSell` instead.
*/
isDoNotSellValue?: boolean;
/**
* @deprecated Never populated by the native SDKs. Use `isTablet` instead.
*/
isTabletValue?: boolean;
hasUserConsent: boolean;
isDoNotSell: boolean;
isTablet: boolean;
countryCode: string;
hasUserConsentValue: boolean;
isAgeRestrictedUserValue: boolean;
isDoNotSellValue: boolean;
isTabletValue: boolean;
}
export interface AdInfo {
@@ -34,11 +17,6 @@ export interface AdInfo {
revenue: number;
}
export interface AdRewardInfo extends AdInfo {
rewardLabel: string;
rewardAmount: number;
}
export enum AdViewPosition {
TOP_CENTER = 'top_center',
TOP_RIGHT = 'top_right',
@@ -50,10 +28,6 @@ export enum AdViewPosition {
BOTTOM_RIGHT = 'bottom_right',
}
/**
* @deprecated Only produced by the now-removed `getConsentDialogState` method
* (removed upstream in cordova-plugin-applovin-max@2.0.0).
*/
export enum ConsentDialogState {
UNKNOWN = 0,
APPLIES = 1,
@@ -106,22 +80,11 @@ export class Applovin extends AwesomeCordovaNativePlugin {
return;
}
/**
* Check whether the SDK has been initialized.
*/
@Cordova()
isInitialized(): Promise<boolean> {
return;
}
@Cordova()
showMediationDebugger(): Promise<any> {
return;
}
/**
* @deprecated Removed upstream in cordova-plugin-applovin-max@2.0.0.
*/
@Cordova()
getConsentDialogState(): Promise<ConsentDialogState> {
return;
@@ -137,17 +100,11 @@ export class Applovin extends AwesomeCordovaNativePlugin {
return;
}
/**
* @deprecated Removed upstream in cordova-plugin-applovin-max@2.0.0.
*/
@Cordova()
setIsAgeRestrictedUser(isAgeRestrictedUser: boolean): Promise<any> {
return;
}
/**
* @deprecated Removed upstream in cordova-plugin-applovin-max@2.0.0.
*/
@Cordova()
isAgeRestrictedUser(): Promise<boolean> {
return;
@@ -173,11 +130,8 @@ export class Applovin extends AwesomeCordovaNativePlugin {
return;
}
/**
* @param {boolean} muted Whether ads should be muted.
*/
@Cordova()
setMuted(muted: boolean): Promise<any> {
setMuted(): Promise<boolean> {
return;
}
@@ -191,19 +145,6 @@ export class Applovin extends AwesomeCordovaNativePlugin {
return;
}
/** SEGMENT TARGETING */
/**
* Add a segment for segment targeting. Must be called before `initialize()`.
*
* @param {number} key The segment key.
* @param {number[]} values The segment values.
*/
@Cordova()
addSegment(key: number, values: number[]): Promise<any> {
return;
}
@Cordova()
trackEvent(event: string, parameters?: object): Promise<any> {
return;
@@ -226,11 +167,6 @@ export class Applovin extends AwesomeCordovaNativePlugin {
return;
}
@Cordova()
updateBannerPosition(adUnitId: string, position: AdViewPosition): Promise<any> {
return;
}
@Cordova()
setBannerExtraParameter(adUnitId: string, key: string, value: string): Promise<any> {
return;
@@ -251,46 +187,6 @@ export class Applovin extends AwesomeCordovaNativePlugin {
return;
}
@Cordova({
eventObservable: true,
event: 'OnBannerAdLoadedEvent',
})
onBannerAdLoaded(): Observable<AdInfo> {
return;
}
@Cordova({
eventObservable: true,
event: 'OnBannerAdLoadFailedEvent',
})
onBannerAdLoadFailed(): Observable<AdInfo> {
return;
}
@Cordova({
eventObservable: true,
event: 'OnBannerAdClickedEvent',
})
onBannerAdClicked(): Observable<AdInfo> {
return;
}
@Cordova({
eventObservable: true,
event: 'OnBannerAdExpandedEvent',
})
onBannerAdExpanded(): Observable<AdInfo> {
return;
}
@Cordova({
eventObservable: true,
event: 'OnBannerAdCollapsedEvent',
})
onBannerAdCollapsed(): Observable<AdInfo> {
return;
}
/** MRECS */
@Cordova()
@@ -308,11 +204,6 @@ export class Applovin extends AwesomeCordovaNativePlugin {
return;
}
@Cordova()
updateMRecPosition(adUnitId: string, position: AdViewPosition): Promise<any> {
return;
}
@Cordova()
setMRecExtraParameter(adUnitId: string, key: string, value: string): Promise<any> {
return;
@@ -333,46 +224,6 @@ export class Applovin extends AwesomeCordovaNativePlugin {
return;
}
@Cordova({
eventObservable: true,
event: 'OnMRecAdLoadedEvent',
})
onMRecAdLoaded(): Observable<AdInfo> {
return;
}
@Cordova({
eventObservable: true,
event: 'OnMRecAdLoadFailedEvent',
})
onMRecAdLoadFailed(): Observable<AdInfo> {
return;
}
@Cordova({
eventObservable: true,
event: 'OnMRecAdClickedEvent',
})
onMRecAdClicked(): Observable<AdInfo> {
return;
}
@Cordova({
eventObservable: true,
event: 'OnMRecAdExpandedEvent',
})
onMRecAdExpanded(): Observable<AdInfo> {
return;
}
@Cordova({
eventObservable: true,
event: 'OnMRecAdCollapsedEvent',
})
onMRecAdCollapsed(): Observable<AdInfo> {
return;
}
/** INTERSTITIALS */
@Cordova()
@@ -380,14 +231,6 @@ export class Applovin extends AwesomeCordovaNativePlugin {
return;
}
/**
* @param {string} adUnitId The ad unit id to check.
*/
@Cordova()
isInterstitialReady(adUnitId: string): Promise<boolean> {
return;
}
@Cordova()
showInterstitial(adUnitId: string, placement?: string): Promise<any> {
return;
@@ -406,14 +249,6 @@ export class Applovin extends AwesomeCordovaNativePlugin {
return;
}
@Cordova({
eventObservable: true,
event: 'OnInterstitialClickedEvent',
})
onInterstitialClicked(): Observable<AdInfo> {
return;
}
@Cordova({
eventObservable: true,
event: 'OnInterstitialLoadFailedEvent',
@@ -453,14 +288,6 @@ export class Applovin extends AwesomeCordovaNativePlugin {
return;
}
/**
* @param {string} adUnitId The ad unit id to check.
*/
@Cordova()
isRewardedAdReady(adUnitId: string): Promise<boolean> {
return;
}
@Cordova()
showRewardedAd(adUnitId: string, placement?: string): Promise<any> {
return;
@@ -479,14 +306,6 @@ export class Applovin extends AwesomeCordovaNativePlugin {
return;
}
@Cordova({
eventObservable: true,
event: 'OnRewardedAdClickedEvent',
})
onRewardedAdClicked(): Observable<AdInfo> {
return;
}
@Cordova({
eventObservable: true,
event: 'OnRewardedAdLoadFailedEvent',
@@ -513,17 +332,9 @@ export class Applovin extends AwesomeCordovaNativePlugin {
@Cordova({
eventObservable: true,
event: 'OnRewardedAdFailedToDisplayEvent',
event: 'OnRewardedAdAdFailedToDisplayEvent',
})
onRewardedAdAdFailedToDisplay(): Observable<AdInfo> {
return;
}
@Cordova({
eventObservable: true,
event: 'OnRewardedAdReceivedRewardEvent',
})
onRewardedAdReceivedReward(): Observable<AdRewardInfo> {
return;
}
}
@@ -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