react-native-qonversion
Version:
Qonversion provides full in-app purchases infrastructure, so you do not need to build your own server for receipt validation. Implement in-app subscriptions, validate user receipts, check subscription status, and provide access to your app features and co
89 lines • 3.6 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const enums_1 = require("./dto/enums");
const QonversionConfig_1 = __importDefault(require("./QonversionConfig"));
class QonversionConfigBuilder {
projectKey;
launchMode;
constructor(projectKey, launchMode) {
this.projectKey = projectKey;
this.launchMode = launchMode;
}
environment = enums_1.Environment.PRODUCTION;
entitlementsCacheLifetime = enums_1.EntitlementsCacheLifetime.MONTH;
entitlementsUpdateListener = undefined;
proxyUrl = undefined;
kidsMode = false;
/**
* Set current application {@link Environment}. Used to distinguish sandbox and production users.
*
* @param environment current environment.
* @return builder instance for chain calls.
*/
setEnvironment(environment) {
this.environment = environment;
return this;
}
/**
* Entitlements cache is used when there are problems with the Qonversion API
* or internet connection. If so, Qonversion will return the last successfully loaded
* entitlements. The current method allows you to configure how long that cache may be used.
* The default value is {@link EntitlementsCacheLifetime.MONTH}.
*
* @param lifetime desired entitlements cache lifetime duration
* @return builder instance for chain calls.
*/
setEntitlementsCacheLifetime(lifetime) {
this.entitlementsCacheLifetime = lifetime;
return this;
}
/**
* Provide a listener to be notified about asynchronous user entitlements updates.
*
* Make sure you provide this listener for being up-to-date with the user entitlements.
* Else you can lose some important updates. Also, please, consider that this listener
* should live for the whole lifetime of the application.
*
* @param entitlementsUpdateListener listener to be called when entitlements update.
* @return builder instance for chain calls.
*/
setEntitlementsUpdateListener(entitlementsUpdateListener) {
this.entitlementsUpdateListener = entitlementsUpdateListener;
return this;
}
/**
* Provide a URL to your proxy server which will redirect all the requests from the app
* to our API. Please, contact us before using this feature.
*
* @param url your proxy server url
* @return builder instance for chain calls.
* @see [The documentation](https://documentation.qonversion.io/docs/custom-proxy-server-for-sdks)
*/
setProxyURL(url) {
this.proxyUrl = url;
return this;
}
/**
* Android only.
* Use this function to enable Qonversion SDK Kids mode.
* With this mode activated, our SDK does not collect any information that violates Google Children’s Privacy Policy.
* @return builder instance for chain calls.
*/
enableKidsMode() {
this.kidsMode = true;
return this;
}
/**
* Generate {@link QonversionConfig} instance with all the provided configurations.
*
* @return the complete {@link QonversionConfig} instance.
*/
build() {
return new QonversionConfig_1.default(this.projectKey, this.launchMode, this.environment, this.entitlementsCacheLifetime, this.entitlementsUpdateListener, this.proxyUrl, this.kidsMode);
}
}
exports.default = QonversionConfigBuilder;
//# sourceMappingURL=QonversionConfigBuilder.js.map