This plugin defines a global entitlement object, which provides methods related to entitlement and purchase .
Although the object is in the global scope, it is not available until after the deviceready event.
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(typeof cq.mobile.entitlement);
}
Installation
cordova plugin add aemm-plugin-entitlement
Object Properties
Offer object Properties
Name
Type
Notes
productId
String
the product/subscription id user input in "Products&Subscription" dashboard
label
String
the product/subscription name user input in "Products&Subscription" dashboard, will be null if not set by the user
description
String
the product/subscription description user input in "Products&Subscription" dashboard, will be null if not set by the user
price
String
price returned from the corresponding store, will be null if product is free
offerType
String
could be "product" or "subscription"
subscriptionType
String
could be "allAccess" or "standard", valid only if offertype is "subscription"
isFree
Boolean
true if the product is set as free in "Products&Subscription" dashboard
SubscriptionInfo object Properties
Name
Type
Notes
subscriptionOffers
Array
an array of Offer objects, would be empty if user has an active subscription
subscriptionState
Object
an SubscriptionState object
SubscriptionState object Properties
Name
Type
Notes
isSubscriber
Boolean
true if the user has been a subscriber at any point in time (i.e. for past and active subscribers alike), note that subscriptionState.isSubscriber = subscriptionState.store.isSubscriber OR subscriptionState.integrator.isSubscriber
isActiveSubscriber
Boolean
true if the user has an active subscription at this point in time, note that subscriptionState.isActiveSubscriber = subscriptionState.store.isActiveSubscriber OR subscriptionState.integrator.isActiveSubscriber
store
Object
a Store object which contains subscription state to product store
integrator
Object
an Integrator object which contains subsciption state to the integrator
Store object Properties
Name
Type
Notes
isSubscriber
Boolean
true if the user has been a subscriber at any point in time (i.e. for past and active subscribers alike)
isActiveSubscriber
Boolean
true if the user has an active subscription at this point in time
expirationDate
Number
the timestamp in milliseconds since the epoch, which represents when that subscription period ends, it could be null since not all subscriptions (both from the store and the integrator) have an expiration date.
subscriptionType
String
could be "allAccess" or "standard", valid only if isSubscriber is true
id
String
product id of the subscription product in the store
Integrator object Properties
Name
Type
Notes
isSubscriber
Boolean
true if the user has been a subscriber at any point in time (i.e. for past and active subscribers alike)
isActiveSubscriber
Boolean
true if the user has an active subscription at this point in time
expirationDate
Number
the timestamp in milliseconds since the epoch, which represents when that subscription period ends , it could be null since not all subscriptions (both from the store and the integrator) have an expiration date.
customData
String
customData will not be set if the sibling isSubscriber is false. If isSubscriber is true, it may or may not be set. customData can be returned by the integrator. It is intended to contain data that is transparent to Adobe and only meaningful to the customer.
Methods
entitlement.getSubscriptionInfo
entitlement.getOffers
entitlement.purchaseOffer
entitlement.restorePurchases
entitlement.getSubscriptionInfo
This method returns the subscription info for the current publication and device.
Parameter
Type
Description
successCallback
Function
The success callback, which accepts a SubscriptionInfo object