diff --git a/docs/plugins/adjust/README.md b/docs/plugins/adjust/README.md index d98d6baf8a..3b0fd1eef7 100644 --- a/docs/plugins/adjust/README.md +++ b/docs/plugins/adjust/README.md @@ -1,7 +1,5 @@ -# Adjust - -``` -$ ionic cordova plugin add com.adjust.sdk +# AdjustThirdPartySharing +ova plugin add com.adjust.sdk $ npm install @awesome-cordova-plugins/adjust ``` diff --git a/docs/plugins/admob-plus/README.md b/docs/plugins/admob-plus/README.md index cdf01fa923..f39a9c28ef 100644 --- a/docs/plugins/admob-plus/README.md +++ b/docs/plugins/admob-plus/README.md @@ -1,4 +1,4 @@ -# AdMob +# RewardVideo ``` $ ionic cordova plugin add cordova-admob-plus @@ -7,18 +7,13 @@ $ npm install @awesome-cordova-plugins/admob-plus ## [Usage Documentation](https://danielsogl.gitbook.io/awesome-cordova-plugins/plugins/admob-plus/) -Plugin Repo: [https://github.com/admob-plus/admob-plus](https://github.com/admob-plus/admob-plus) +Plugin Repo: []() -## Supported platforms - -- Android - - iOS - - +github.com/admob-plus/admob-plus](https://github.com/admob-plus/admob-plus) -n-admob-free, which provides a cleaner API and build with modern tools. +AdMob Plus is the successor of cordova-plugin-admob-free, which provides a cleaner API and build with modern tools. ## Supported platforms diff --git a/docs/plugins/cashfree-pg/README.md b/docs/plugins/cashfree-pg/README.md index af635ca2e2..db682f0f66 100644 --- a/docs/plugins/cashfree-pg/README.md +++ b/docs/plugins/cashfree-pg/README.md @@ -1,7 +1,5 @@ -# CFPaymentGateway - -``` -$ ionic cordova plugin add cordova-plugin-cashfree-pg +# CFPaymentComponentBuilder +nic cordova plugin add cordova-plugin-cashfree-pg $ npm install @awesome-cordova-plugins/cashfree-pg ``` diff --git a/docs/plugins/fabric/README.md b/docs/plugins/fabric/README.md index 67f09a290d..6b0435dc4e 100644 --- a/docs/plugins/fabric/README.md +++ b/docs/plugins/fabric/README.md @@ -1,4 +1,4 @@ -# Answers +# Crashlytics ``` $ ionic cordova plugin add cordova-fabric-plugin --variable FABRIC_API_KEY=XXX --variable FABRIC_API_SECRET=xxx @@ -9,7 +9,7 @@ $ npm install @awesome-cordova-plugins/fabric Plugin Repo: [https://www.npmjs.com/package/cordova-fabric-plugin](https://www.npmjs.com/package/cordova-fabric-plugin) -API for interacting with the Answers kit. +API for interacting with the Crashlytics kit. https://docs.fabric.io/crashlytics/index.html @@ -20,7 +20,3 @@ https://docs.fabric.io/crashlytics/index.html -OS - - - diff --git a/docs/plugins/firebase-model/README.md b/docs/plugins/firebase-model/README.md new file mode 100644 index 0000000000..3ca641076a --- /dev/null +++ b/docs/plugins/firebase-model/README.md @@ -0,0 +1,45 @@ +# FirebaseModelInput +Result +t +cordova plugin add cordova-plugin-firebase-model +$ npm install @awesome-cordova-plugins/firebase-model +``` + +## [Usage Documentation](https://danielsogl.gitbook.io/awesome-cordova-plugins/plugins/firebase-model/) + +Plugin Repo: ['']('') + +This plugin downloads the TensorFlow model from firebase and classify the images. + +```typescript +import { FirebaseModel } from '@ionic-native/ionic-native-firebase-model'; + + +constructor(private firebaseModel: FirebaseModel) { } + +... + + +this.firebaseModel.configure('Sample_Model') + .subscribe((res: FirebaseModelConfigResult) => console.log(res.status + " - " + res.progress)) + .catch((error: any) => console.error(error)); + + +try { + var result:FirebaseModelClassifyResult = await this.firebaseModel.classify("/Documents/input_image.png") + console.log(result.label + " - " + result.score) + +} +catch (e) { + console.log(e) +} + + +``` + +## Supported platforms + +- iOS + + + diff --git a/docs/plugins/hyper-track/README.md b/docs/plugins/hyper-track/README.md index 8582480b34..d1a04f840a 100644 --- a/docs/plugins/hyper-track/README.md +++ b/docs/plugins/hyper-track/README.md @@ -1,5 +1,4 @@ -# HyperTrack - +# Coordinates alidationError ic cordova plugin add cordova-plugin-hypertrack-v3 $ npm install @awesome-cordova-plugins/hyper-track diff --git a/docs/plugins/nfc/README.md b/docs/plugins/nfc/README.md index 03ea032ec5..158c32e133 100644 --- a/docs/plugins/nfc/README.md +++ b/docs/plugins/nfc/README.md @@ -1,5 +1,7 @@ -# TextHelper -ionic cordova plugin add phonegap-nfc +# NFC + +``` +$ ionic cordova plugin add phonegap-nfc $ npm install @awesome-cordova-plugins/nfc ``` diff --git a/docs/plugins/purchases/README.md b/docs/plugins/purchases/README.md index 5a276cab92..bfbab32da9 100644 --- a/docs/plugins/purchases/README.md +++ b/docs/plugins/purchases/README.md @@ -1,7 +1,7 @@ # Purchases ``` -$ ionic cordova plugin add cordova-plugin-purchases@3.2.1 +$ ionic cordova plugin add cordova-plugin-purchases@5.0.0 $ npm install @awesome-cordova-plugins/purchases ``` @@ -9,7 +9,9 @@ $ npm install @awesome-cordova-plugins/purchases Plugin Repo: [https://github.com/RevenueCat/cordova-plugin-purchases](https://github.com/RevenueCat/cordova-plugin-purchases) -Purchases is a cross platform solution for managing in-app subscriptions. A backend is also provided via [RevenueCat](https://www.revenuecat.com) +*Purchases* is a client for the [RevenueCat](https://www.revenuecat.com/) subscription and purchase tracking system. +It is an open source framework that provides a wrapper around `BillingClient`, `StoreKit` and the RevenueCat backend +to make implementing in-app subscriptions easy - receipt validation and status tracking included! ## Features | | RevenueCat | @@ -24,9 +26,24 @@ Purchases is a cross platform solution for managing in-app subscriptions. A back | 📮 | Great support - [Help Center](https://revenuecat.zendesk.com) | | 🤩 | Awesome [new features](https://trello.com/b/RZRnWRbI/revenuecat-product-roadmap) | +## Capacitor + +The Cordova plugin is not guaranteed to be up to date and we are moving our efforts to the Capacitor plugin. +Please consider using our [Capacitor plugin](https://docs.revenuecat.com/docs/capacitor) instead of the Cordova plugin and this wrapper. + ## Getting Started -For more detailed information, you can view our complete documentation at [docs.revenuecat.com](https://docs.revenuecat.com/docs). +Please follow the [Quickstart Guide](https://docs.revenuecat.com/docs/) for more information on how to use the SDK + +## Latest changes to this plugin + +This latest release updates the plugin to use BillingClient 6 in Android. If you come from an older version of the +RevenueCat SDK, see [Android Native - 5.x to 6.x Migration](https://www.revenuecat.com/docs/android-native-5x-to-6x-migration) +for a more thorough explanation of the new Google subscription model announced with BillingClient 5 and how to take advantage of it. + +If your app supports product changes using [DEFERRED replacement mode](https://www.revenuecat.com/docs/managing-subscriptions#google-play), +then you can either stick with the previous major version until support for DEFERRED is re-introduced in this major version, +or you can remove DEFERRED replacement options from your app. ## Supported platforms diff --git a/docs/plugins/save-dialog/README.md b/docs/plugins/save-dialog/README.md index d19e9a0553..b45e32caf9 100644 --- a/docs/plugins/save-dialog/README.md +++ b/docs/plugins/save-dialog/README.md @@ -1,6 +1,6 @@ -# Save Dialog +# SaveDialog -```text +``` $ ionic cordova plugin add cordova-plugin-save-dialog $ npm install @awesome-cordova-plugins/save-dialog ``` @@ -9,12 +9,12 @@ $ npm install @awesome-cordova-plugins/save-dialog Plugin Repo: [https://github.com/Amphiluke/cordova-plugin-save-dialog](https://github.com/Amphiluke/cordova-plugin-save-dialog) -This Cordova plugin displays the native Save dialog which allows users to store a file in the selected location. +Plugin displays the native Save dialog which allows users to store a file in the selected location. ## Supported platforms -* Android -* iOS - +- Android + - iOS + diff --git a/docs/plugins/sign-in-with-apple/README.md b/docs/plugins/sign-in-with-apple/README.md index ea3a8e30f4..a2076b9c09 100644 --- a/docs/plugins/sign-in-with-apple/README.md +++ b/docs/plugins/sign-in-with-apple/README.md @@ -1,7 +1,5 @@ -# Sign In With Apple - -``` -$ ionic cordova plugin add cordova-plugin-sign-in-with-apple +# ASAuthorizationAppleIDRequest +c cordova plugin add cordova-plugin-sign-in-with-apple $ npm install @awesome-cordova-plugins/sign-in-with-apple ``` diff --git a/docs/plugins/smtp-client/README.md b/docs/plugins/smtp-client/README.md index 564b8ebc4f..7f57fb7a05 100644 --- a/docs/plugins/smtp-client/README.md +++ b/docs/plugins/smtp-client/README.md @@ -14,4 +14,7 @@ Plugin Repo: [https://github.com/CWBudde/cordova-plugin-smtp-client](https://git ## Supported platforms - Android -- iOS + - iOS + + + diff --git a/docs/plugins/tealium/README.md b/docs/plugins/tealium/README.md index 9ee3e4a3ba..730f4f577b 100644 --- a/docs/plugins/tealium/README.md +++ b/docs/plugins/tealium/README.md @@ -1,7 +1,5 @@ -# Tealium - -``` -$ '' +# ConsentExpiry + '' $ npm install @awesome-cordova-plugins/tealium ``` diff --git a/docs/plugins/unvired-cordova-sdk/README.md b/docs/plugins/unvired-cordova-sdk/README.md index da595b83d6..9848c3c1e1 100644 --- a/docs/plugins/unvired-cordova-sdk/README.md +++ b/docs/plugins/unvired-cordova-sdk/README.md @@ -1,7 +1,7 @@ -# Unvired Cordova SDK - -``` -$ ionic cordova plugin add @awesome-cordova-plugins/unvired-cordova-sdk +# SyncResult +ult +ivateResult +ionic cordova plugin add @awesome-cordova-plugins/unvired-cordova-sdk $ npm install @awesome-cordova-plugins/unvired-cordova-sdk ``` diff --git a/docs/plugins/wonderpush/README.md b/docs/plugins/wonderpush/README.md index f771b97c99..03d7394b6a 100644 --- a/docs/plugins/wonderpush/README.md +++ b/docs/plugins/wonderpush/README.md @@ -1,4 +1,5 @@ -# Push Notifications - WonderPush +# UserPreferencesMethods +nderPush ``` $ ionic cordova plugin add wonderpush-cordova-sdk --variable CLIENT_ID=YOUR_CLIENT_ID --variable CLIENT_SECRET=YOUR_CLIENT_SECRET diff --git a/src/@awesome-cordova-plugins/plugins/purchases/index.ts b/src/@awesome-cordova-plugins/plugins/purchases/index.ts index 23e5093181..351e11d8ab 100644 --- a/src/@awesome-cordova-plugins/plugins/purchases/index.ts +++ b/src/@awesome-cordova-plugins/plugins/purchases/index.ts @@ -55,6 +55,23 @@ export enum BILLING_FEATURE { PRICE_CHANGE_CONFIRMATION, } +export enum REFUND_REQUEST_STATUS { + /** + * Apple has received the refund request. + */ + SUCCESS, + + /** + * User canceled submission of the refund request. + */ + USER_CANCELLED, + + /** + * There was an error with the request. See message for more details. + */ + ERROR, +} + export enum PRORATION_MODE { UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0, @@ -78,10 +95,11 @@ export enum PRORATION_MODE { IMMEDIATE_WITHOUT_PRORATION = 3, /** - * Replacement takes effect when the old plan expires, and the new price will - * be charged at the same time. + * Replacement takes effect immediately, and the user is charged full price + * of new plan and is given a full billing cycle of subscription, + * plus remaining prorated time from the old plan. */ - DEFERRED = 4, + IMMEDIATE_AND_CHARGE_FULL_PRICE = 5, } export enum PACKAGE_TYPE { @@ -150,10 +168,113 @@ export enum INTRO_ELIGIBILITY_STATUS { INTRO_ELIGIBILITY_STATUS_NO_INTRO_OFFER_EXISTS, } +export enum LOG_LEVEL { + VERBOSE = 'VERBOSE', + DEBUG = 'DEBUG', + INFO = 'INFO', + WARN = 'WARN', + ERROR = 'ERROR', +} + +/** + * Enum for in-app message types. + * This can be used if you disable automatic in-app message from showing automatically. + * Then, you can pass what type of messages you want to show in the `showInAppMessages` + * method in Purchases. + */ +export enum IN_APP_MESSAGE_TYPE { + // Make sure the enum values are in sync with those defined in iOS/Android + /** + * In-app messages to indicate there has been a billing issue charging the user. + */ + BILLING_ISSUE = 0, + + /** + * iOS-only. This message will show if you increase the price of a subscription and + * the user needs to opt-in to the increase. + */ + PRICE_INCREASE_CONSENT = 1, + + /** + * iOS-only. StoreKit generic messages. + */ + GENERIC = 2, +} + +export enum PRODUCT_CATEGORY { + /** + * A type of product for non-subscription. + */ + NON_SUBSCRIPTION = 'NON_SUBSCRIPTION', + + /** + * A type of product for subscriptions. + */ + SUBSCRIPTION = 'SUBSCRIPTION', + + /** + * A type of product for unknowns. + */ + UNKNOWN = 'UNKNOWN', +} + +/** + * Recurrence mode for a pricing phase + */ +export enum RECURRENCE_MODE { + /** + * Pricing phase repeats infinitely until cancellation + */ + INFINITE_RECURRING = 1, + + /** + * Pricing phase repeats for a fixed number of billing periods + */ + FINITE_RECURRING = 2, + + /** + * Pricing phase does not repeat + */ + NON_RECURRING = 3, +} + +/** + * Payment mode for offer pricing phases. Google Play only. + */ +export enum OFFER_PAYMENT_MODE { + /** + * Subscribers don't pay until the specified period ends + */ + FREE_TRIAL = 'FREE_TRIAL', + + /** + * Subscribers pay up front for a specified period + */ + SINGLE_PAYMENT = 'SINGLE_PAYMENT', + + /** + * Subscribers pay a discounted amount for a specified number of periods + */ + DISCOUNTED_RECURRING_PAYMENT = 'DISCOUNTED_RECURRING_PAYMENT', +} + +/** + * Time duration unit for Period. + */ +export enum PERIOD_UNIT { + DAY = 'DAY', + WEEK = 'WEEK', + MONTH = 'MONTH', + YEAR = 'YEAR', + UNKNOWN = 'UNKNOWN', +} + /** * @name Purchases * @description - * Purchases is a cross platform solution for managing in-app subscriptions. A backend is also provided via [RevenueCat](https://www.revenuecat.com) + * *Purchases* is a client for the [RevenueCat](https://www.revenuecat.com/) subscription and purchase tracking system. + * It is an open source framework that provides a wrapper around `BillingClient`, `StoreKit` and the RevenueCat backend + * to make implementing in-app subscriptions easy - receipt validation and status tracking included! * * ## Features * | | RevenueCat | @@ -168,36 +289,30 @@ export enum INTRO_ELIGIBILITY_STATUS { * | 📮 | Great support - [Help Center](https://revenuecat.zendesk.com) | * | 🤩 | Awesome [new features](https://trello.com/b/RZRnWRbI/revenuecat-product-roadmap) | * - * ## Getting Started + * ## Capacitor * - * For more detailed information, you can view our complete documentation at [docs.revenuecat.com](https://docs.revenuecat.com/docs). - * @usage - * #### 1. Get a RevenueCat API key + * The Cordova plugin is not guaranteed to be up to date and we are moving our efforts to the Capacitor plugin. + * Please consider using our [Capacitor plugin](https://docs.revenuecat.com/docs/capacitor) instead of the Cordova plugin and this wrapper. * - * Log in to the [RevenueCat dashboard](https://app.revenuecat.com) and obtain a free API key for your application. + * ## Getting Started * - * #### 2. Initialize the SDK + * Please follow the [Quickstart Guide](https://docs.revenuecat.com/docs/) for more information on how to use the SDK * - * You should only configure _Purchases_ once (usually on app launch) as soon as your app has a unique user id for your user. This can be when a user logs in if you have accounts or on launch if you can generate a random user identifier. + * ## Latest changes to this plugin * - * ```typescript - * import { Platform } from "@ionic/angular"; - * import { Purchases } from "@awesome-cordova-plugins/purchases/ngx"; + * This latest release updates the plugin to use BillingClient 6 in Android. If you come from an older version of the + * RevenueCat SDK, see [Android Native - 5.x to 6.x Migration](https://www.revenuecat.com/docs/android-native-5x-to-6x-migration) + * for a more thorough explanation of the new Google subscription model announced with BillingClient 5 and how to take advantage of it. * - * constructor(public platform: Platform, private purchases: Purchases) { - * platform.ready().then(() => { - * this.purchases.setDebugLogsEnabled(true); // Enable to get debug logs - * this.purchases.configure("my_api_key", "my_app_user_id"); - * } - * } - * ``` + * If your app supports product changes using [DEFERRED replacement mode](https://www.revenuecat.com/docs/managing-subscriptions#google-play), + * then you can either stick with the previous major version until support for DEFERRED is re-introduced in this major version, + * or you can remove DEFERRED replacement options from your app. * - * #### 3. Quickstart - * Please follow the [Quickstart Guide](https://docs.revenuecat.com/docs/) for more information on how to use the SDK + * @usage * * ### Requirements - * Requires XCode 11.0+ and minimum target iOS 9.0+ - * This plugin has been tested with cordova-plugin-purchases@ + * Requires XCode 13.2+ and minimum target iOS 11.0+ + * This plugin has been tested with cordova-plugin-purchases@5.x.x * @interfaces * PurchasesError * IntroEligibility @@ -213,7 +328,7 @@ export enum INTRO_ELIGIBILITY_STATUS { */ @Plugin({ pluginName: 'Purchases', - plugin: 'cordova-plugin-purchases@3.2.1', + plugin: 'cordova-plugin-purchases@5.0.0', pluginRef: 'Purchases', // the variable reference to call the plugin, example: navigator.geolocation repo: 'https://github.com/RevenueCat/cordova-plugin-purchases', // the github repository URL for the plugin platforms: ['Android', 'iOS'], // Array of platforms supported, example: ['Android', 'iOS'] @@ -238,6 +353,13 @@ export class Purchases extends AwesomeCordovaNativePlugin { */ static PURCHASE_TYPE = PURCHASE_TYPE; + /** + * Supported product categories. + * @readonly + * @enum {string} + */ + public static PRODUCT_CATEGORY = PRODUCT_CATEGORY; + /** * Enum for billing features. * Currently, these are only relevant for Google Play Android users: @@ -245,6 +367,13 @@ export class Purchases extends AwesomeCordovaNativePlugin { */ static BILLING_FEATURE = BILLING_FEATURE; + /** + * Enum with possible return states for beginning refund request. + * @readonly + * @enum {string} + */ + static REFUND_REQUEST_STATUS = REFUND_REQUEST_STATUS; + /** * Replace SKU's ProrationMode. * @@ -269,12 +398,28 @@ export class Purchases extends AwesomeCordovaNativePlugin { */ static INTRO_ELIGIBILITY_STATUS = INTRO_ELIGIBILITY_STATUS; + /** + * Enum of different possible log levels. + * + * @readonly + * @enum {string} + */ + static LOG_LEVEL = LOG_LEVEL; + + /** + * Enum of different possible in-app message types. + * + * @readonly + * @enum {string} + */ + static IN_APP_MESSAGE_TYPE = IN_APP_MESSAGE_TYPE; + /** * @deprecated Use {@link configureWith} instead. It accepts a {@link PurchasesConfiguration} object which offers more flexibility. * * Sets up Purchases with your API key and an app user id. * - * @param {string} apiKey RevenueCat API Key. Needs to be a String + * @param {string} apiKey RevenueCat API Key. Needs to be a string * @param {string?} appUserID A unique id for identifying the user * @param {boolean} observerMode An optional boolean. Set this to TRUE if you have your own IAP implementation and * want to use only RevenueCat's backend. Default is FALSE. If you are on Android and setting this to ON, you will have @@ -288,15 +433,15 @@ export class Purchases extends AwesomeCordovaNativePlugin { /** * Sets up Purchases with your API key and an app user id. - * @param {PurchasesConfiguration} Object containing configuration parameters + * @param {PurchasesConfiguration} configuration containing configuration parameters */ @Cordova({ sync: true }) - configureWith({ apiKey, appUserID, observerMode, userDefaultsSuiteName, useAmazon }: PurchasesConfiguration): void {} + configureWith(configuration: PurchasesConfiguration): void {} /** * Gets the Offerings configured in the dashboard * - * @returns {Promise} Will return a [PurchasesError] if the offerings are not properly configured in RevenueCat or if there is another error retrieving them. + * @returns Will return a [PurchasesError] if the offerings are not properly configured in RevenueCat or if there is another error retrieving them. */ @Cordova() getOfferings(): Promise { @@ -328,8 +473,6 @@ export class Purchases extends AwesomeCordovaNativePlugin { * @param {UpgradeInfo} upgradeInfo Android only. Optional UpgradeInfo you wish to upgrade from containing the oldSKU * and the optional prorationMode. * @param {PURCHASE_TYPE} type Optional type of product, can be inapp or subs. Subs by default - * @returns {Promise} A [PurchasesError] is triggered after an error or when the user cancels the purchase. - * If user cancelled, userCancelled will be true */ @Cordova({ successIndex: 1, @@ -343,14 +486,42 @@ export class Purchases extends AwesomeCordovaNativePlugin { return; } + /** + * Make a purchase + * + * @param {PurchasesStoreProduct} product The product you want to purchase + * @param {GoogleProductChangeInfo} googleProductChangeInfo Android only. Optional GoogleProductChangeInfo you + * wish to upgrade from containing the oldProductIdentifier and the optional prorationMode. + * @param {boolean} googleIsPersonalizedPrice Android and Google only. Optional boolean indicates personalized pricing on products available for purchase in the EU. + * For compliance with EU regulations. User will see "This price has been customized for you" in the purchase dialog when true. + * See https://developer.android.com/google/play/billing/integrate#personalized-price for more info. + * + */ + @Cordova({ + successIndex: 1, + errorIndex: 2, + }) + purchaseStoreProduct( + product: PurchasesStoreProduct, + googleProductChangeInfo?: GoogleProductChangeInfo | null, + googleIsPersonalizedPrice = false + ): Promise<{ productIdentifier: string; customerInfo: CustomerInfo }> { + return; + } + /** * Make a purchase * * @param {PurchasesPackage} aPackage The Package you wish to purchase. You can get the Packages by calling getOfferings * @param {UpgradeInfo} upgradeInfo Android only. Optional UpgradeInfo you wish to upgrade from containing the oldSKU * and the optional prorationMode. - * @returns {Promise} A [PurchasesError] is triggered after an error or when the user cancels the purchase. - * If user cancelled, userCancelled will be true + * @param {GoogleProductChangeInfo} googleProductChangeInfo Android only. Optional GoogleProductChangeInfo you + * wish to upgrade from containing the oldProductIdentifier and the optional prorationMode. + * @param {boolean} googleIsPersonalizedPrice Android and Google only. Optional boolean indicates personalized pricing + * on products available for purchase in the EU. For compliance with EU regulations. + * User will see "This price has been customized for you" in the purchase dialog when true. + * See https://developer.android.com/google/play/billing/integrate#personalized-price for more info. + * */ @Cordova({ successIndex: 1, @@ -358,7 +529,34 @@ export class Purchases extends AwesomeCordovaNativePlugin { }) purchasePackage( aPackage: PurchasesPackage, - upgradeInfo?: UpgradeInfo | null + upgradeInfo?: UpgradeInfo | null, + googleProductChangeInfo?: GoogleProductChangeInfo | null, + googleIsPersonalizedPrice = false + ): Promise<{ productIdentifier: string; customerInfo: CustomerInfo }> { + return; + } + + /** + * Google only. Make a purchase of a subscriptionOption + * + * @param {SubscriptionOption} subscriptionOption The SubscriptionOption you wish to purchase. You can get the + * SubscriptionOption from StoreProducts by calling getOfferings + * @param {GoogleProductChangeInfo} googleProductChangeInfo Android only. Optional GoogleProductChangeInfo you + * wish to upgrade from containing the oldProductIdentifier and the optional prorationMode. + * @param {boolean} googleIsPersonalizedPrice Android and Google only. Optional boolean indicates personalized pricing + * on products available for purchase in the EU. For compliance with EU regulations. + * User will see "This price has been customized for you" in the purchase dialog when true. + * See https://developer.android.com/google/play/billing/integrate#personalized-price for more info. + * + */ + @Cordova({ + successIndex: 1, + errorIndex: 2, + }) + public static purchaseSubscriptionOption( + subscriptionOption: SubscriptionOption, + googleProductChangeInfo?: GoogleProductChangeInfo | null, + googleIsPersonalizedPrice = false ): Promise<{ productIdentifier: string; customerInfo: CustomerInfo }> { return; } @@ -366,7 +564,6 @@ export class Purchases extends AwesomeCordovaNativePlugin { /** * Restores a user's previous purchases and links their appUserIDs to any user's also using those purchases. * - * @returns {Promise} Errors are of type [PurchasesError] */ @Cordova() restorePurchases(): Promise { @@ -375,8 +572,6 @@ export class Purchases extends AwesomeCordovaNativePlugin { /** * Get the appUserID that is currently in placed in the SDK - * - * @returns {string} */ @Cordova({ sync: true }) getAppUserID(): string { @@ -388,8 +583,6 @@ export class Purchases extends AwesomeCordovaNativePlugin { * to identify a user without calling configure. * * @param {string} appUserID The appUserID that should be linked to the currently user - * @returns {Promise} an object that contains the customerInfo after logging in, as well as a boolean indicating - * whether the user has just been created for the first time in the RevenueCat backend. */ @Cordova() logIn(appUserID: string): Promise { @@ -399,8 +592,6 @@ export class Purchases extends AwesomeCordovaNativePlugin { /** * Logs out the Purchases client clearing the saved appUserID. This will generate a random user id and save it in the cache. * If the current user is already anonymous, this will produce a PurchasesError. - * - * @returns {Promise} new purchaser info after resetting. */ @Cordova() logOut(): Promise { @@ -410,9 +601,6 @@ export class Purchases extends AwesomeCordovaNativePlugin { /** * Gets the current purchaser info. This call will return the cached purchaser info unless the cache is stale, in which case, * it will make a network call to retrieve it from the servers. - * - * @returns {Promise} Errors are of type [PurchasesError] and get normally triggered if there - * is an error retrieving the purchaser info. */ @Cordova() getCustomerInfo(): Promise { @@ -421,8 +609,6 @@ export class Purchases extends AwesomeCordovaNativePlugin { /** * Returns an observable that can be used to receive updates on the purchaser info - * - * @returns {Observable} */ @Cordova({ eventObservable: true, @@ -434,6 +620,8 @@ export class Purchases extends AwesomeCordovaNativePlugin { } /** + * @deprecated Use {@link setLogLevel} instead. + * * Enables/Disables debugs logs * * @param {boolean} enabled true to enable debug logs, false to disable @@ -442,13 +630,22 @@ export class Purchases extends AwesomeCordovaNativePlugin { setDebugLogsEnabled(enabled: boolean): void {} /** - * This method will send all the purchases to the RevenueCat backend. Call this when using your own implementation - * for subscriptions anytime a sync is needed, like after a successful purchase. + * Used to set the log level. Useful for debugging issues with the lovely team @RevenueCat. + * @param {LOG_LEVEL} level the minimum log level to enable. + */ + @Cordova({ sync: true }) + setLogLevel(level: LOG_LEVEL): void {} + + /** + * Set a custom log handler for redirecting logs to your own logging system. + * By default, this sends info, warning, and error messages. + * If you wish to receive Debug level messages, see [setLogLevel]. * - * @warning This function should only be called if you're not calling purchaseProduct. + * @param {LogHandler} logHandler It will get called for each log event. + * Use this function to redirect the log to your own logging system */ @Cordova({ sync: true }) - syncPurchases(): void {} + setLogHandler(logHandler: LogHandler): void {} /** * iOS only. @@ -459,6 +656,36 @@ export class Purchases extends AwesomeCordovaNativePlugin { @Cordova({ sync: true }) setSimulatesAskToBuyInSandbox(enabled: boolean): void {} + /** + * This method will send all the purchases to the RevenueCat backend. Call this when using your own implementation + * for subscriptions anytime a sync is needed, like after a successful purchase. + * + * @warning This function should only be called if you're not calling purchaseProduct. + */ + @Cordova({ sync: true }) + syncPurchases(): void {} + + /** + * This method will send a purchase to the RevenueCat backend. This function should only be called if you are + * in Amazon observer mode or performing a client side migration of your current users to RevenueCat. + * + * The receipt IDs are cached if successfully posted so they are not posted more than once. + * + * @param {string} productID Product ID associated to the purchase. + * @param {string} receiptID ReceiptId that represents the Amazon purchase. + * @param {string} amazonUserID Amazon's userID. This parameter will be ignored when syncing a Google purchase. + * @param {(string|null|undefined)} isoCurrencyCode Product's currency code in ISO 4217 format. + * @param {(number|null|undefined)} price Product's price. + */ + @Cordova({ sync: true }) + syncObserverModeAmazonPurchase( + productID: string, + receiptID: string, + amazonUserID: string, + isoCurrencyCode?: string | null, + price?: number | null + ): void {} + /** * Enable automatic collection of Apple Search Ads attribution. Disabled by default. * @@ -474,8 +701,6 @@ export class Purchases extends AwesomeCordovaNativePlugin { enableAdServicesAttributionTokenCollection(): void {} /** - * @returns {Promise} A boolean indicating if the `appUserID` has been generated - * by RevenueCat or not. */ @Cordova({ sync: true }) isAnonymous(): boolean { @@ -493,7 +718,6 @@ export class Purchases extends AwesomeCordovaNativePlugin { * pricing, to not create a misleading situation. To avoid this, make sure you are testing with the latest version of * iOS so that the subscription group can be collected by the SDK. Android always returns INTRO_ELIGIBILITY_STATUS_UNKNOWN. * @param productIdentifiers Array of product identifiers for which you want to compute eligibility - * @returns { Promise> } Map of IntroEligibility per productId */ @Cordova() checkTrialOrIntroductoryPriceEligibility( @@ -519,7 +743,6 @@ export class Purchases extends AwesomeCordovaNativePlugin { * Removes a given ShouldPurchasePromoProductListener * * @param {ShouldPurchasePromoProductListener} listenerToRemove ShouldPurchasePromoProductListener reference of the listener to remove - * @returns {boolean} True if listener was removed, false otherwise */ @Cordova({ sync: true }) removeShouldPurchasePromoProductListener(listenerToRemove: ShouldPurchasePromoProductListener): boolean { @@ -738,7 +961,7 @@ export class Purchases extends AwesomeCordovaNativePlugin { * * @param features An array of feature types to check for support. Feature types must be one of * [BILLING_FEATURE]. By default, is an empty list and no specific feature support will be checked. - * @returns {Promise} Or [PurchasesError] if there is an error. + * */ @Cordova() canMakePayments(features: BILLING_FEATURE[] = []): Promise { @@ -752,6 +975,67 @@ export class Purchases extends AwesomeCordovaNativePlugin { */ @Cordova({ sync: true }) setProxyURL(url: string): void {} + + /** + * iOS 15+ only. Presents a refund request sheet in the current window scene for + * the latest transaction associated with the active entitlement. + * + * If the request was unsuccessful, no active entitlements could be found for + * the user, or multiple active entitlements were found for the user, + * the promise will return an error. + * If called in an unsupported platform (iOS < 15), an `unsupportedError` will be sent to the callback. + * + * Important: This method should only be used if your user can only have a single active entitlement at a given time. + * If a user could have more than one entitlement at a time, use `beginRefundRequestForEntitlement` instead. + * + */ + @Cordova() + beginRefundRequestForActiveEntitlement(): Promise { + return; + } + + /** + * iOS 15+ only. Presents a refund request sheet in the current window scene for + * the latest transaction associated with the `entitlement`. + * + * If the request was unsuccessful, the promise will return an error. + * If called in an unsupported platform (iOS < 15), an `unsupportedError` will be sent to the callback. + * + * @param entitlementInfo The entitlement to begin a refund request for. + * + */ + @Cordova() + beginRefundRequestForEntitlement(entitlementInfo: PurchasesEntitlementInfo): Promise { + return; + } + + /** + * iOS 15+ only. Presents a refund request sheet in the current window scene for + * the latest transaction associated with the `product`. + * + * If the request was unsuccessful, the promise will return an error. + * If called in an unsupported platform (iOS < 15), an `unsupportedError` will be sent to the callback. + * + * @param storeProduct The StoreProduct to begin a refund request for. + * + */ + @Cordova() + beginRefundRequestForProduct(storeProduct: PurchasesStoreProduct): Promise { + return; + } + + /** + * Shows in-app messages available from the App Store or Google Play. You need to disable messages from showing + * automatically using [PurchasesConfiguration.shouldShowInAppMessagesAutomatically]. + * + * Note: In iOS, this requires version 16+. In older versions the promise will be resolved successfully + * immediately. + * + * @param messageTypes An array of message types that the stores can display inside your app. Must be one of + * [IN_APP_MESSAGE_TYPE]. By default, is undefined and all message types will be shown. + */ + @Cordova({ sync: true }) + showInAppMessages(messageTypes?: IN_APP_MESSAGE_TYPE[]): void {} } /** * The EntitlementInfo object gives you access to all of the information about the status of a user entitlement. @@ -767,7 +1051,6 @@ export interface PurchasesEntitlementInfo { readonly isActive: boolean; /** * True if the underlying subscription is set to renew at the end of the billing period (expirationDate). - * Will always be True if entitlement is for lifetime access. */ readonly willRenew: boolean; /** @@ -834,7 +1117,6 @@ export interface PurchasesEntitlementInfos { readonly activeInCurrentEnvironment: { [key: string]: PurchasesEntitlementInfo }; /** * Dictionary of active ``EntitlementInfo`` objects keyed by their identifiers. - * * @note: these can be active on any environment. */ readonly activeInAnyEnvironment: { [key: string]: PurchasesEntitlementInfo }; @@ -1002,6 +1284,7 @@ export interface PurchasesStoreProduct { readonly priceString: string; /** * Currency code for price and original price. + * Contains the currency code value of defaultOption for Google Play. */ readonly currencyCode: string; /** @@ -1012,6 +1295,34 @@ export interface PurchasesStoreProduct { * Collection of discount offers for a product. Null for Android. */ readonly discounts: PurchasesStoreProductDiscount[] | null; + + /** + * Product category. + */ + readonly productCategory: PRODUCT_CATEGORY | null; + + /** + * Subscription period, specified in ISO 8601 format. For example, + * P1W equates to one week, P1M equates to one month, + * P3M equates to three months, P6M equates to six months, + * and P1Y equates to one year. + * Note: Not available for Amazon. + */ + readonly subscriptionPeriod: string | null; + + /** + * Default subscription option for a product. Google Play only. + */ + readonly defaultOption: SubscriptionOption | null; + /** + * Collection of subscription options for a product. Google Play only. + */ + readonly subscriptionOptions: SubscriptionOption[] | null; + /** + * Offering identifier the store product was presented from. + * Null if not using offerings or if fetched directly from store via getProducts. + */ + readonly presentedOfferingIdentifier: string | null; } /** @@ -1050,6 +1361,13 @@ export interface PurchasesOffering { * Offering description defined in RevenueCat dashboard. */ readonly serverDescription: string; + /** + * Offering metadata defined in RevenueCat dashboard. To access values, you need + * to check the type beforehand. For example: + * const my_unknown_value: unknown = offering.metadata['my_key']; + * const my_string_value: string | undefined = typeof(my_unknown_value) === 'string' ? my_unknown_value : undefined; + */ + readonly metadata: { [key: string]: unknown }; /** * Array of `Package` objects available for purchase. */ @@ -1120,6 +1438,20 @@ export interface UpgradeInfo { readonly prorationMode?: PRORATION_MODE; } +/** + * Holds the information used when upgrading from another sku. For Android use only. + */ +export interface GoogleProductChangeInfo { + /** + * The old product identifier to upgrade from. + */ + readonly oldProductIdentifier: string; + /** + * The [PRORATION_MODE] to use when upgrading the given oldSKU. + */ + readonly prorationMode?: PRORATION_MODE; +} + /** * Holds the introductory price status */ @@ -1172,10 +1504,185 @@ export interface PurchasesConfiguration { * suite, otherwise it will use standardUserDefaults. Default is null, which will make the SDK use standardUserDefaults. */ userDefaultsSuiteName?: string; + /** + * iOS-only, will be ignored for Android. + * Set this to TRUE to enable StoreKit2. + * Default is FALSE. + * + * @deprecated RevenueCat currently uses StoreKit 1 for purchases, as its stability in production scenarios has + * proven to be more performant than StoreKit 2. + * We're collecting more data on the best approach, but StoreKit 1 vs StoreKit 2 is an implementation detail + * that you shouldn't need to care about. + * We recommend not using this parameter, letting RevenueCat decide for you which StoreKit implementation to use. + */ + usesStoreKit2IfAvailable?: boolean; /** * An optional boolean. Android only. Required to configure the plugin to be used in the Amazon Appstore. */ useAmazon?: boolean; + /** + * Whether we should show store in-app messages automatically. Both Google Play and the App Store provide in-app + * messages for some situations like billing issues. By default, those messages will be shown automatically. + * This allows to disable that behavior, so you can display those messages at your convenience. For more information, + * check: https://rev.cat/storekit-message and https://rev.cat/googleplayinappmessaging + */ + shouldShowInAppMessagesAutomatically?: boolean; +} + +/** + * Contains all details associated with a SubscriptionOption + * Used only for Google + */ +export interface SubscriptionOption { + /** + * Identifier of the subscription option + * If this SubscriptionOption represents a base plan, this will be the basePlanId. + * If it represents an offer, it will be {basePlanId}:{offerId} + */ + readonly id: string; + + /** + * Identifier of the StoreProduct associated with this SubscriptionOption + * This will be {subId}:{basePlanId} + */ + readonly storeProductId: string; + + /** + * Identifer of the subscription associated with this SubscriptionOption + * This will be {subId} + */ + readonly productId: string; + + /** + * Pricing phases defining a user's payment plan for the product over time. + */ + readonly pricingPhases: PricingPhase[]; + + /** + * Tags defined on the base plan or offer. Empty for Amazon. + */ + readonly tags: string[]; + + /** + * True if this SubscriptionOption represents a subscription base plan (rather than an offer). + */ + readonly isBasePlan: boolean; + + /** + * The subscription period of fullPricePhase (after free and intro trials). + */ + readonly billingPeriod: Period | null; + + /** + * True if the subscription is pre-paid. + */ + readonly isPrepaid: boolean; + + /** + * The full price PricingPhase of the subscription. + * Looks for the last price phase of the SubscriptionOption. + */ + readonly fullPricePhase: PricingPhase | null; + + /** + * The free trial PricingPhase of the subscription. + * Looks for the first pricing phase of the SubscriptionOption where amountMicros is 0. + * There can be a freeTrialPhase and an introductoryPhase in the same SubscriptionOption. + */ + readonly freePhase: PricingPhase | null; + + /** + * The intro trial PricingPhase of the subscription. + * Looks for the first pricing phase of the SubscriptionOption where amountMicros is greater than 0. + * There can be a freeTrialPhase and an introductoryPhase in the same SubscriptionOption. + */ + readonly introPhase: PricingPhase | null; + + /** + * Offering identifier the subscription option was presented from + */ + readonly presentedOfferingIdentifier: string | null; +} + +/** + * Contains all the details associated with a PricingPhase + */ +export interface PricingPhase { + /** + * Billing period for which the PricingPhase applies + */ + readonly billingPeriod: Period; + + /** + * Recurrence mode of the PricingPhase + */ + readonly recurrenceMode: RECURRENCE_MODE | null; + + /** + * Number of cycles for which the pricing phase applies. + * Null for infiniteRecurring or finiteRecurring recurrence modes. + */ + readonly billingCycleCount: number | null; + + /** + * Price of the PricingPhase + */ + readonly price: Price; + + /** + * Indicates how the pricing phase is charged for finiteRecurring pricing phases + */ + readonly offerPaymentMode: OFFER_PAYMENT_MODE | null; +} + +/** + * Contains all the details associated with a Price + */ +export interface Price { + /** + * Formatted price of the item, including its currency sign. For example $3.00 + */ + readonly formatted: string; + + /** + * Price in micro-units, where 1,000,000 micro-units equal one unit of the currency. + * + * For example, if price is "€7.99", price_amount_micros is 7,990,000. This value represents + * the localized, rounded price for a particular currency. + */ + readonly amountMicros: number; + + /** + * Returns ISO 4217 currency code for price and original price. + * + * For example, if price is specified in British pounds sterling, price_currency_code is "GBP". + * If currency code cannot be determined, currency symbol is returned. + */ + readonly currencyCode: string; +} + +/** + * Contains all the details associated with a Period + */ +export interface Period { + /** + * The number of period units: day, week, month, year, unknown + */ + readonly unit: PERIOD_UNIT; + + /** + * The increment of time that a subscription period is specified in + */ + readonly value: number; + + /** + * Specified in ISO 8601 format. For example, P1W equates to one week, + * P1M equates to one month, P3M equates to three months, P6M equates to six months, + * and P1Y equates to one year + */ + readonly iso8601: string; } export type ShouldPurchasePromoProductListener = (deferredPurchase: () => void) => void; + +export type LogHandler = (logLevel: LOG_LEVEL, message: string) => void;