-
public class Purchasely
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classPurchasely.BuilderBuilder class for configuring the PurchaseLy SDK. Must be called before method start() configure SDK.
-
Field Summary
Fields Modifier and Type Field Description private final static <ERROR CLASS>anonymousUserIdprivate static ObjectplayerViewprivate static Function0<ImageView>lottieViewprivate static EventListenereventListenerprivate static UIListeneruiListenerprivate static PurchaseListenerpurchaseListenerprivate static LogLevellogLevelprivate static BooleanrecordLogsprivate static PLYAppTechnologyappTechnologyprivate static StringsdkBridgeVersionprivate final static StringsdkVersionprivate static BooleanreadyToOpenDeeplinkprivate static PLYRunningModerunningModeprivate static Localelanguagepublic final static PurchaselyINSTANCE
-
Method Summary
Modifier and Type Method Description final static UnituserLogin(String userId, Function1<Boolean, Unit> callback)final static UnituserLogout()final static BooleanisAnonymous()final static UnitaddLogger(PLYLogging logging)final static LiveData<PLYPlan>livePurchase()Provide a stream of purchased plans. final LiveData<State>getPurchaseStateLiveData()Retrieve the current purchase state. final StateFlow<State>getPurchaseState()Retrieve the current purchase state. final static Unitstart(Function2<Boolean, PLYError, Unit> initialized)Mandatory function to start using SDK. final static Unitstart()Mandatory function to start using SDK. final static Unitclose()Release resources and clear all references to your activities. final static PLYPresentationViewpresentationView(Context context, PLYPresentationViewProperties properties, @Nullable() Function2<PLYProductViewResult, PLYPlan, Unit> callback)Retrieve view to display a presentation. final static PLYPresentationViewpresentationView(Context context, PLYPresentationViewProperties properties)Retrieve view to display a presentation. final static PLYPresentationViewpresentationViewForPlacement(Context context, String placementId, String contentId, Function1<Boolean, Unit> onLoaded, Function0<Unit> onClose, @Nullable() Function2<PLYProductViewResult, PLYPlan, Unit> callback)Retrieve view to display a presentation final static PLYPresentationViewpresentationViewForPlacement(Context context, String placementId, String contentId, Function1<Boolean, Unit> onLoaded, Function0<Unit> onClose)Retrieve view to display a presentation final static PLYPresentationViewpresentationViewForPlacement(Context context, String placementId, String contentId, Function0<Unit> onClose)Retrieve view to display a presentation final static PLYPresentationViewpresentationViewForPlacement(Context context, String placementId, Function0<Unit> onClose)Retrieve view to display a presentation final static PLYPresentationViewpresentationViewForPlacement(Context context, Function0<Unit> onClose)Retrieve view to display a presentation final static UnitfetchPresentation(PLYPresentationViewProperties properties, @NonNull() Function2<PLYPresentation, PLYError, Unit> callback)Fetch a presentation for the provided properties and invokes the callback upon completion. final static UnitfetchPresentationForPlacement(String placementId, @NonNull() Function2<PLYPresentation, PLYError, Unit> callback)Fetch a presentation corresponding to placementId and invokes the callback upon completion. final static UnitclientPresentationDisplayed(PLYPresentation presentation)final static UnitclientPresentationClosed(PLYPresentation presentation)final static UnitallProducts(Function1<List<PLYProduct>, Unit> onSuccess, Function1<Throwable, Unit> onError)Retrieve list of products for purchase. final static UnitallProducts(ProductsListener callback)Retrieve list of products for purchase. final List<PLYProduct>allProducts()Retrieve list of products for purchase. final PLYProductproduct(String vendorId)Retrieve the product having vendorId. final static Unitproduct(String vendorId, Function1<PLYProduct, Unit> onSuccess, Function1<Throwable, Unit> onError)Retrieve the product having vendorId. final static Unitproduct(String vendorId, ProductListener callback)Retrieve the product having vendorId. final PLYPlanplan(String vendorId)Retrieve the plan having vendorId. final static Unitplan(String vendorId, Function1<PLYPlan, Unit> onSuccess, Function1<Throwable, Unit> onError)Retrieve the plan having vendorId. final static Unitplan(String vendorId, PlanListener callback)Retrieve the plan having vendorId. final static Unitpurchase(Activity activity, PLYPlan plan, PLYPromoOffer offer, String contentId, Function1<PLYPlan, Unit> onSuccess, Function1<PLYError, Unit> onError)Purchase a plan directly. final static UnitrestoreAllProducts(Function1<PLYPlan, Unit> onSuccess, Function1<PLYError, Unit> onError)Initiate restoration for all previous purchases. final static UnitsilentRestoreAllProducts(Function1<PLYPlan, Unit> onSuccess, Function1<PLYError, Unit> onError)Restore previous purchases. final static Unitsynchronize()Synchronize purchases from your own in-app purchase system with Purchasely. final static UnitdisplaySubscriptionCancellationInstruction(Activity activity, @StyleRes() Integer themeId)Display a dialog informing the user how to cancel his subscription. final static PLYPurchaseFragmentsubscriptionsFragment()final static UnituserSubscriptions(SubscriptionsListener callback)Retrieve user's subscriptions information. final static UnituserSubscriptions(Function1<List<PLYSubscriptionData>, Unit> onSuccess, Function1<Throwable, Unit> onError)Retrieve user's subscriptions information. final List<PLYSubscriptionData>userSubscriptions()Retrieve user's subscriptions information. final static UnitpurchaseHistory(Function1<List<PLYPlan>, Unit> onSuccess, Function1<Throwable, Unit> onError)Retrieve the purchase history. final List<PLYPlan>purchaseHistory()Retrieve the purchase history. final <ERROR CLASS>isPastSubscriber()final static <ERROR CLASS>isPastSubscriber(Function1<Boolean, Unit> result)Check whether the user is a past subscriber. final static BooleanisDeeplinkHandled(Uri deeplink)Add deeplink to the queue. final static UnitsetAttribute(Attribute attribute, String value)final static UnitsetAttributes(HashMap<Attribute, String> attributes)final static UnitsetPaywallActionsInterceptor(Function4<PLYPresentationInfo, PLYPresentationAction, PLYPresentationActionParameters, Function1<Boolean, Unit>, Unit> handler)final static UnitsetPaywallActionsInterceptor(PLYPaywallActionListener handler)final static UnitsetDefaultPresentationResultHandler(Function2<PLYProductViewResult, PLYPlan, Unit> handler)final static UnituserDidConsumeSubscriptionContent()final static List<String>retrieveLogs()Retrieve recorded logs from the PurchaseLy SDK. final static ObjectuserAttribute(String key)Retrieve the value of a user attribute. final static Map<String, Object>userAttributes()Retrieve all user attributes. final static UnitsetUserAttribute(String key, String value)Set a user attribute with a String value. final static UnitsetUserAttribute(String key, Integer value)Set a user attribute with an Int value. final static UnitsetUserAttribute(String key, Float value)Set a user attribute with a Float value. final static UnitsetUserAttribute(String key, Boolean value)Set a user attribute with a Boolean value. final static UnitsetUserAttribute(String key, Date value)Set a user attribute with a Date value. final static UnitsetUserAttribute(String key, Instant value)Set a user attribute with an Instant value. final static UnitsetUserAttributes(Map<String, Object> map)Set multiple user attributes. final static UnitclearUserAttributes()Clear all user attributes. final static UnitclearUserAttribute(String key)Clear a specific user attribute. final static <ERROR CLASS>getAnonymousUserId()final static ObjectgetPlayerView()Your can provide your own video player It must implements PLYPlayerInterface final static UnitsetPlayerView(Object playerView)Your can provide your own video player It must implements PLYPlayerInterface final static Function0<ImageView>getLottieView()Your can provide your own lottie view It must implements PLYLottieInterface final static UnitsetLottieView(Function0<ImageView> lottieView)Your can provide your own lottie view It must implements PLYLottieInterface final static EventListenergetEventListener()Listener for purchase events. final static UnitsetEventListener(EventListener eventListener)Listener for purchase events. final static UIListenergetUiListener()Listener for UI events. final static UnitsetUiListener(UIListener uiListener)Listener for UI events. final static PurchaseListenergetPurchaseListener()Listener for purchase events. final static UnitsetPurchaseListener(PurchaseListener purchaseListener)Listener for purchase events. final static LogLevelgetLogLevel()The log level used by the Purchasely SDK. final static UnitsetLogLevel(LogLevel logLevel)The log level used by the Purchasely SDK. final static BooleangetRecordLogs()Whether to record logs. final static UnitsetRecordLogs(Boolean recordLogs)Whether to record logs. final static PLYAppTechnologygetAppTechnology()The technology used by the Purchasely SDK. final static UnitsetAppTechnology(PLYAppTechnology appTechnology)The technology used by the Purchasely SDK. final static StringgetSdkBridgeVersion()The version of the Purchasely SDK bridge (non-native). final static UnitsetSdkBridgeVersion(String sdkBridgeVersion)The version of the Purchasely SDK bridge (non-native). final static StringgetSdkVersion()The version of the Purchasely SDK. final static BooleangetReadyToOpenDeeplink()Whether the SDK is ready to open deep links. final static UnitsetReadyToOpenDeeplink(Boolean readyToOpenDeeplink)final static PLYRunningModegetRunningMode()The running mode of the Purchasely SDK. final static UnitsetRunningMode(PLYRunningMode runningMode)The running mode of the Purchasely SDK. final static LocalegetLanguage()The language used by the Purchasely SDK. final static UnitsetLanguage(Locale language)The language used by the Purchasely SDK. -
-
Method Detail
-
userLogout
final static Unit userLogout()
-
isAnonymous
final static Boolean isAnonymous()
-
addLogger
final static Unit addLogger(PLYLogging logging)
-
livePurchase
final static LiveData<PLYPlan> livePurchase()
Provide a stream of purchased plans.
-
getPurchaseStateLiveData
final LiveData<State> getPurchaseStateLiveData()
Retrieve the current purchase state.
-
getPurchaseState
final StateFlow<State> getPurchaseState()
Retrieve the current purchase state.
-
start
final static Unit start(Function2<Boolean, PLYError, Unit> initialized)
Mandatory function to start using SDK. Must be called with building SDK with Purchasely.Builder.
- Parameters:
initialized- callback indicating successful configuration and providing a PLYError in case of errors.
-
start
final static Unit start()
Mandatory function to start using SDK. Must be called with building SDK with Purchasely.Builder.
-
presentationView
@JvmOverloads() final static PLYPresentationView presentationView(Context context, PLYPresentationViewProperties properties, @Nullable() Function2<PLYProductViewResult, PLYPlan, Unit> callback)
Retrieve view to display a presentation.
- Parameters:
context- android context.properties- the presentation properties.callback- listener for a purchase or an error with associated plan.
-
presentationView
@JvmOverloads() final static PLYPresentationView presentationView(Context context, PLYPresentationViewProperties properties)
Retrieve view to display a presentation.
- Parameters:
context- android context.properties- the presentation properties.
-
presentationViewForPlacement
@JvmOverloads() final static PLYPresentationView presentationViewForPlacement(Context context, String placementId, String contentId, Function1<Boolean, Unit> onLoaded, Function0<Unit> onClose, @Nullable() Function2<PLYProductViewResult, PLYPlan, Unit> callback)
Retrieve view to display a presentation
- Parameters:
context- android context.placementId- id of placement to display.contentId- id of the content to display.onLoaded- callback invoked when the presentation is loaded and ready to be displayed.onClose- callback invoked when the presentation is closed.callback- listener for a purchase or an error with associated plan.
-
presentationViewForPlacement
@JvmOverloads() final static PLYPresentationView presentationViewForPlacement(Context context, String placementId, String contentId, Function1<Boolean, Unit> onLoaded, Function0<Unit> onClose)
Retrieve view to display a presentation
- Parameters:
context- android context.placementId- id of placement to display.contentId- id of the content to display.onLoaded- callback invoked when the presentation is loaded and ready to be displayed.onClose- callback invoked when the presentation is closed.
-
presentationViewForPlacement
@JvmOverloads() final static PLYPresentationView presentationViewForPlacement(Context context, String placementId, String contentId, Function0<Unit> onClose)
Retrieve view to display a presentation
- Parameters:
context- android context.placementId- id of placement to display.contentId- id of the content to display.onClose- callback invoked when the presentation is closed.
-
presentationViewForPlacement
@JvmOverloads() final static PLYPresentationView presentationViewForPlacement(Context context, String placementId, Function0<Unit> onClose)
Retrieve view to display a presentation
- Parameters:
context- android context.placementId- id of placement to display.onClose- callback invoked when the presentation is closed.
-
presentationViewForPlacement
@JvmOverloads() final static PLYPresentationView presentationViewForPlacement(Context context, Function0<Unit> onClose)
Retrieve view to display a presentation
- Parameters:
context- android context.onClose- callback invoked when the presentation is closed.
-
fetchPresentation
@JvmOverloads() final static Unit fetchPresentation(PLYPresentationViewProperties properties, @NonNull() Function2<PLYPresentation, PLYError, Unit> callback)
Fetch a presentation for the provided properties and invokes the callback upon completion.
- Parameters:
properties- The properties of the presentation view.callback- callback providing the fetched PLYPresentation or a PLYError.
-
fetchPresentationForPlacement
@JvmOverloads() final static Unit fetchPresentationForPlacement(String placementId, @NonNull() Function2<PLYPresentation, PLYError, Unit> callback)
Fetch a presentation corresponding to placementId and invokes the callback upon completion.
- Parameters:
placementId- id of the placement for which to fetch the presentation..callback- callback to be invoked with the fetched PLYPresentation or a PLYError.
-
clientPresentationDisplayed
final static Unit clientPresentationDisplayed(PLYPresentation presentation)
-
clientPresentationClosed
final static Unit clientPresentationClosed(PLYPresentation presentation)
-
allProducts
final static Unit allProducts(Function1<List<PLYProduct>, Unit> onSuccess, Function1<Throwable, Unit> onError)
Retrieve list of products for purchase.
- Parameters:
onSuccess- callback to receive the list of retrieved products.onError- callback to handle errors during product retrieval.
-
allProducts
final static Unit allProducts(ProductsListener callback)
Retrieve list of products for purchase.
- Parameters:
callback- callback to receive product information or handle errors.
-
allProducts
final List<PLYProduct> allProducts()
Retrieve list of products for purchase.
-
product
final PLYProduct product(String vendorId)
Retrieve the product having vendorId.
- Parameters:
vendorId- the vendor id of the product to fetch.
-
product
final static Unit product(String vendorId, Function1<PLYProduct, Unit> onSuccess, Function1<Throwable, Unit> onError)
Retrieve the product having vendorId.
- Parameters:
vendorId- the vendor id of the product to fetch.onSuccess- callback for successful product retrieval.onError- callback for handling errors during product retrieval.
-
product
final static Unit product(String vendorId, ProductListener callback)
Retrieve the product having vendorId.
- Parameters:
vendorId- the vendor id of the product to fetch.callback- callback listener to receive product information or handle errors.
-
plan
final PLYPlan plan(String vendorId)
Retrieve the plan having vendorId.
- Parameters:
vendorId- the vendor id of the plan to fetch.
-
plan
final static Unit plan(String vendorId, Function1<PLYPlan, Unit> onSuccess, Function1<Throwable, Unit> onError)
Retrieve the plan having vendorId.
- Parameters:
vendorId- the vendor id of the plan to fetch.onSuccess- callback for successful plan retrieval.onError- callback for successful plan retrieval.
-
plan
final static Unit plan(String vendorId, PlanListener callback)
Retrieve the plan having vendorId.
- Parameters:
vendorId- the vendor id of the plan to fetch.callback- callback listener to receive plan information or handle errors.
-
purchase
final static Unit purchase(Activity activity, PLYPlan plan, PLYPromoOffer offer, String contentId, Function1<PLYPlan, Unit> onSuccess, Function1<PLYError, Unit> onError)
Purchase a plan directly.
- Parameters:
activity- the android activity from which the purchase process is initiated.plan- the PLYPlan to be purchased.offer- the PLYPromoOffer for the purchase.contentId- the content id associated to the purchase.onSuccess- callback to handle successful purchase results.onError- callback to handle errors during the purchase process.
-
restoreAllProducts
final static Unit restoreAllProducts(Function1<PLYPlan, Unit> onSuccess, Function1<PLYError, Unit> onError)
Initiate restoration for all previous purchases.
- Parameters:
onSuccess- callback to handle successful restoration results.onError- callback to handle errors during the restoration process.
-
silentRestoreAllProducts
final static Unit silentRestoreAllProducts(Function1<PLYPlan, Unit> onSuccess, Function1<PLYError, Unit> onError)
Restore previous purchases.
- Parameters:
onSuccess- callback to handle successful restoration results.onError- callback to handle errors during the restoration process.
-
synchronize
final static Unit synchronize()
Synchronize purchases from your own in-app purchase system with Purchasely. Only useful in observer mode
-
displaySubscriptionCancellationInstruction
final static Unit displaySubscriptionCancellationInstruction(Activity activity, @StyleRes() Integer themeId)
Display a dialog informing the user how to cancel his subscription.
- Parameters:
activity- Activity instance.themeId- Resource identifier to set a custom style to dialog.
-
subscriptionsFragment
final static PLYPurchaseFragment subscriptionsFragment()
-
userSubscriptions
final static Unit userSubscriptions(SubscriptionsListener callback)
Retrieve user's subscriptions information.
- Parameters:
callback- callback to receive user's subscription information or handle errors.
-
userSubscriptions
final static Unit userSubscriptions(Function1<List<PLYSubscriptionData>, Unit> onSuccess, Function1<Throwable, Unit> onError)
Retrieve user's subscriptions information.
- Parameters:
onSuccess- callback to receive user's subscription information.onError- callback to handle errors during subscription retrieval.
-
userSubscriptions
final List<PLYSubscriptionData> userSubscriptions()
Retrieve user's subscriptions information.
-
purchaseHistory
final static Unit purchaseHistory(Function1<List<PLYPlan>, Unit> onSuccess, Function1<Throwable, Unit> onError)
Retrieve the purchase history.
- Parameters:
onSuccess- callback to receive the list of purchased plans.onError- callback to handle errors during purchase history retrieval.
-
purchaseHistory
final List<PLYPlan> purchaseHistory()
Retrieve the purchase history.
-
isPastSubscriber
final <ERROR CLASS> isPastSubscriber()
-
isPastSubscriber
final static <ERROR CLASS> isPastSubscriber(Function1<Boolean, Unit> result)
Check whether the user is a past subscriber.
-
isDeeplinkHandled
final static Boolean isDeeplinkHandled(Uri deeplink)
Add deeplink to the queue.
-
setAttribute
final static Unit setAttribute(Attribute attribute, String value)
-
setAttributes
final static Unit setAttributes(HashMap<Attribute, String> attributes)
-
setPaywallActionsInterceptor
final static Unit setPaywallActionsInterceptor(Function4<PLYPresentationInfo, PLYPresentationAction, PLYPresentationActionParameters, Function1<Boolean, Unit>, Unit> handler)
-
setPaywallActionsInterceptor
final static Unit setPaywallActionsInterceptor(PLYPaywallActionListener handler)
-
setDefaultPresentationResultHandler
final static Unit setDefaultPresentationResultHandler(Function2<PLYProductViewResult, PLYPlan, Unit> handler)
-
userDidConsumeSubscriptionContent
final static Unit userDidConsumeSubscriptionContent()
-
retrieveLogs
final static List<String> retrieveLogs()
Retrieve recorded logs from the PurchaseLy SDK.
-
userAttribute
final static Object userAttribute(String key)
Retrieve the value of a user attribute.
- Parameters:
key- The key of the user attribute.
-
userAttributes
final static Map<String, Object> userAttributes()
Retrieve all user attributes.
-
setUserAttribute
final static Unit setUserAttribute(String key, String value)
Set a user attribute with a String value.
- Parameters:
key- the key of the user attribute.value- the String value to set.
-
setUserAttribute
final static Unit setUserAttribute(String key, Integer value)
Set a user attribute with an Int value.
- Parameters:
key- the key of the user attribute.value- the Int value to set.
-
setUserAttribute
final static Unit setUserAttribute(String key, Float value)
Set a user attribute with a Float value.
- Parameters:
key- the key of the user attribute.value- the Float value to set.
-
setUserAttribute
final static Unit setUserAttribute(String key, Boolean value)
Set a user attribute with a Boolean value.
- Parameters:
key- the key of the user attribute.value- the Boolean value to set.
-
setUserAttribute
final static Unit setUserAttribute(String key, Date value)
Set a user attribute with a Date value.
- Parameters:
key- the key of the user attribute.value- the Date value to set.
-
setUserAttribute
@RequiresApi(value = 26) final static Unit setUserAttribute(String key, Instant value)
Set a user attribute with an Instant value.
- Parameters:
key- the key of the user attribute.value- the Instant value to set.
-
setUserAttributes
final static Unit setUserAttributes(Map<String, Object> map)
Set multiple user attributes.
- Parameters:
map- a map containing key-value pairs of user attributes.
-
clearUserAttributes
final static Unit clearUserAttributes()
Clear all user attributes.
-
clearUserAttribute
final static Unit clearUserAttribute(String key)
Clear a specific user attribute.
- Parameters:
key- the key of the user attribute to clear.
-
getAnonymousUserId
final static <ERROR CLASS> getAnonymousUserId()
-
getPlayerView
final static Object getPlayerView()
Your can provide your own video player It must implements PLYPlayerInterface
-
setPlayerView
final static Unit setPlayerView(Object playerView)
Your can provide your own video player It must implements PLYPlayerInterface
-
getLottieView
final static Function0<ImageView> getLottieView()
Your can provide your own lottie view It must implements PLYLottieInterface
-
setLottieView
final static Unit setLottieView(Function0<ImageView> lottieView)
Your can provide your own lottie view It must implements PLYLottieInterface
-
getEventListener
final static EventListener getEventListener()
Listener for purchase events.
-
setEventListener
final static Unit setEventListener(EventListener eventListener)
Listener for purchase events.
-
getUiListener
final static UIListener getUiListener()
Listener for UI events.
-
setUiListener
final static Unit setUiListener(UIListener uiListener)
Listener for UI events.
-
getPurchaseListener
final static PurchaseListener getPurchaseListener()
Listener for purchase events.
-
setPurchaseListener
final static Unit setPurchaseListener(PurchaseListener purchaseListener)
Listener for purchase events.
-
getLogLevel
final static LogLevel getLogLevel()
The log level used by the Purchasely SDK.
-
setLogLevel
final static Unit setLogLevel(LogLevel logLevel)
The log level used by the Purchasely SDK.
-
getRecordLogs
final static Boolean getRecordLogs()
Whether to record logs.
-
setRecordLogs
final static Unit setRecordLogs(Boolean recordLogs)
Whether to record logs.
-
getAppTechnology
final static PLYAppTechnology getAppTechnology()
The technology used by the Purchasely SDK.
-
setAppTechnology
final static Unit setAppTechnology(PLYAppTechnology appTechnology)
The technology used by the Purchasely SDK.
-
getSdkBridgeVersion
final static String getSdkBridgeVersion()
The version of the Purchasely SDK bridge (non-native).
-
setSdkBridgeVersion
final static Unit setSdkBridgeVersion(String sdkBridgeVersion)
The version of the Purchasely SDK bridge (non-native).
-
getSdkVersion
final static String getSdkVersion()
The version of the Purchasely SDK.
-
getReadyToOpenDeeplink
final static Boolean getReadyToOpenDeeplink()
Whether the SDK is ready to open deep links.
-
setReadyToOpenDeeplink
final static Unit setReadyToOpenDeeplink(Boolean readyToOpenDeeplink)
-
getRunningMode
final static PLYRunningMode getRunningMode()
The running mode of the Purchasely SDK.
-
setRunningMode
final static Unit setRunningMode(PLYRunningMode runningMode)
The running mode of the Purchasely SDK.
-
getLanguage
final static Locale getLanguage()
The language used by the Purchasely SDK.
-
setLanguage
final static Unit setLanguage(Locale language)
The language used by the Purchasely SDK.
-
-
-
-