1.2.1 • Published 1 month ago

@joinflux/capacitor-subscriptions v1.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

@joinflux/capacitor-subscriptions

Subscriptions via Revenue Cat

Versioning

  • Use version 1.x.x for Capacitor 5 support
  • Use version 0.x.x for Capacitor 4 support

Install

npm install @joinflux/capacitor-subscriptions
npx cap sync

API

configure(...)

configure(options: { apiKey: string; appUserID?: string; }) => void

configure initializes the plugin

ParamType
options{ apiKey: string; appUserID?: string; }

logIn(...)

logIn(options: { userId: string; email?: string; displayName?: string; }) => Promise<void>

logIn identifies the app user (a user is initially 'anonymous' user on app startup). The user's ID is required but email and display name are optional (just for convenience - saves us from having to look up these details in other systems). NOTE: The email and display name are only updated after the user ID is successfully set and empty strings are ignored/treated the same as undefined.

ParamType
options{ userId: string; email?: string; displayName?: string; }

logOut()

logOut() => Promise<void>

logOut logs out the currently logged in user


getProduct(...)

getProduct(options: { id: string; }) => Promise<Product | undefined>

getProduct retrives the product with the specified id

ParamType
options{ id: string; }

Returns: Promise<Product>


getEligibleOffer(...)

getEligibleOffer(options: { productId: string; offerId: string; }) => Promise<Offer | undefined>

getEligibleOffer returns the offer with the specified ID, for the specified product that the user is eligible for

  • In IOS, searches through Promotional Offers
  • In Android, searches through Offers with a discounted price (excludes free trial)
ParamType
options{ productId: string; offerId: string; }

Returns: Promise<Offer>


purchaseProduct(...)

purchaseProduct(options: { productId: string; offerId?: string; }) => Promise<void>

purchaseProduct initiates the native store purchase (i.e. triggers the native pop-up).

ParamType
options{ productId: string; offerId?: string; }

checkIntroOfferEligibility(...)

checkIntroOfferEligibility(options: { productId: string; }) => Promise<IntroEligibility>

checkIntroOfferEligibility computes whether or not a user is eligible for the introductory pricing period of a given product. IOS: You should use this method to determine whether or not you show the user the normal product price or the introductory price. This also applies to trials (trials are considered a type of introductory pricing).

ParamType
options{ productId: string; }

Returns: Promise<IntroEligibility>


syncPurchases()

syncPurchases() => Promise<void>

syncPurchases synchronizes the current App Store/Play Store account's purchases/transactions to RevenueCat. This is particularly useful for purchases/transactions done outside the app. For example: redeeming an IOS Offer code in the App Store. See https://www.revenuecat.com/docs/migrating-existing-subscriptions#client-side-migration for more info.

NOTE that syncPurchases should only be called when necessary due to potential pit falls such as unintentionally aliasing accounts. See https://www.revenuecat.com/docs/restoring-purchases#syncpurchases-considerations for more info.


setDeviceIdentifiers()

setDeviceIdentifiers() => Promise<void>

setDeviceIdentifiers automatically collects then sets the user's device identifiers (such as Google Ad ID, IOS IDFA/IDFV, etc.) in their Subscriber attributes. This is primarily for ad/marketing attribution purposes. Note that for IOS 14.5+, if the user allows the App Tracking, this method should be called again to update the user's IDFA in RevenueCat.


setAdvertisementAttribution(...)

setAdvertisementAttribution(data: AdvertisementAttribution) => Promise<void>

setAdvertisementAttribution sets the advertisement-related attribution data in the user's Subscriber attributes. Note that if a property is not included (or undefined) or is an empty string, it is not updated in RevenueCat.

ParamType
dataPartial<{ appsFlyerId: string; mediaSource: string; campaign: string; adGroup: string; ad: string; keyword: string; creative: string; }>

Interfaces

Product

PropTypeDescription
identifierstringProduct Id.
pricenumberPrice of the product in the local currency.
priceStringstringFormatted price of the item, including its currency sign, such as €3.99.
introPriceIntroPrice | nullIntroductory price. - IOS: corresponds to the introductory offer (if it exists) - Android: corresponds to the first free trial offer

IntroPrice

PropTypeDescription
pricenumberPrice in the local currency.
priceStringstringFormatted price, including its currency sign, such as €3.99.
cyclesnumberNumber of subscription billing periods for which the user will be given the discount, such as 3.
periodstringBilling period of the discount, specified in ISO 8601 format.
periodUnitstringUnit for the billing period of the discount, can be DAY, WEEK, MONTH or YEAR.
periodNumberOfUnitsnumberNumber of units for the billing period of the discount.

Offer

PropTypeDescription
identifierstringIdentifier of the discount.
pricenumberPrice in the local currency.
priceStringstringFormatted price, including its currency sign, such as €3.99.
cyclesnumberNumber of subscription billing periods for which the user will be given the discount, such as 3.
periodstringBilling period of the discount, specified in ISO 8601 format.
periodUnitstringUnit for the billing period of the discount, can be DAY, WEEK, MONTH or YEAR.
periodNumberOfUnitsnumberNumber of units for the billing period of the discount.

IntroEligibility

Holds the introductory price status

PropTypeDescription
statusINTRO_ELIGIBILITY_STATUSThe introductory price eligibility status
descriptionstringDescription of the status

Type Aliases

AdvertisementAttribution

AdvertisementAttribution represents various ad properties for conversion attribution.

Partial<{ appsFlyerId: string; mediaSource: string; campaign: string; adGroup: string; ad: string; keyword: string; creative: string; }>

Partial

Make all properties in T optional

{ P in keyof T?: TP; }

Enums

INTRO_ELIGIBILITY_STATUS

MembersValueDescription
INTRO_ELIGIBILITY_STATUS_UNKNOWN0RevenueCat doesn't have enough information to determine eligibility.
INTRO_ELIGIBILITY_STATUS_INELIGIBLEThe user is not eligible for a free trial or intro pricing for this product.
INTRO_ELIGIBILITY_STATUS_ELIGIBLEThe user is eligible for a free trial or intro pricing for this product.
INTRO_ELIGIBILITY_STATUS_NO_INTRO_OFFER_EXISTSThere is no free trial or intro pricing for this product.
1.2.1

1 month ago

1.2.0

8 months ago

1.1.0

8 months ago

1.0.1

8 months ago

1.0.0

11 months ago

0.2.0

11 months ago

0.1.0

12 months ago

0.0.10

12 months ago

0.0.9

12 months ago

0.0.8

12 months ago

0.0.7

12 months ago

0.0.6

12 months ago

0.0.5

12 months ago

0.0.4

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago