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
74 lines • 3.24 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_native_1 = require("react-native");
const Mapper_1 = __importDefault(require("./Mapper"));
const { RNAutomations } = react_native_1.NativeModules;
const EVENT_SCREEN_SHOWN = "automations_screen_shown";
const EVENT_ACTION_STARTED = "automations_action_started";
const EVENT_ACTION_FAILED = "automations_action_failed";
const EVENT_ACTION_FINISHED = "automations_action_finished";
const EVENT_AUTOMATIONS_FINISHED = "automations_finished";
class AutomationsInternal {
setDelegate(delegate) {
AutomationsInternal.subscribe(delegate);
}
setNotificationsToken(token) {
RNAutomations.setNotificationsToken(token);
}
async handleNotification(notificationData) {
try {
return await RNAutomations.handleNotification(notificationData);
}
catch (e) {
return false;
}
}
async getNotificationCustomPayload(notificationData) {
try {
return await RNAutomations.getNotificationCustomPayload(notificationData) ?? null;
}
catch (e) {
return null;
}
}
async showScreen(screenId) {
return await RNAutomations.showScreen(screenId);
}
setScreenPresentationConfig(config, screenId) {
const data = Mapper_1.default.convertScreenPresentationConfig(config);
RNAutomations.setScreenPresentationConfig(data, screenId);
}
static subscribe(automationsDelegate) {
const eventEmitter = new react_native_1.NativeEventEmitter(RNAutomations);
eventEmitter.removeAllListeners(EVENT_SCREEN_SHOWN);
eventEmitter.addListener(EVENT_SCREEN_SHOWN, payload => {
const screenId = payload["screenId"] ?? "";
automationsDelegate.automationsDidShowScreen(screenId);
});
eventEmitter.removeAllListeners(EVENT_ACTION_STARTED);
eventEmitter.addListener(EVENT_ACTION_STARTED, payload => {
const actionResult = Mapper_1.default.convertActionResult(payload);
automationsDelegate.automationsDidStartExecuting(actionResult);
});
eventEmitter.removeAllListeners(EVENT_ACTION_FAILED);
eventEmitter.addListener(EVENT_ACTION_FAILED, payload => {
const actionResult = Mapper_1.default.convertActionResult(payload);
automationsDelegate.automationsDidFailExecuting(actionResult);
});
eventEmitter.removeAllListeners(EVENT_ACTION_FINISHED);
eventEmitter.addListener(EVENT_ACTION_FINISHED, payload => {
const actionResult = Mapper_1.default.convertActionResult(payload);
automationsDelegate.automationsDidFinishExecuting(actionResult);
});
eventEmitter.removeAllListeners(EVENT_AUTOMATIONS_FINISHED);
eventEmitter.addListener(EVENT_AUTOMATIONS_FINISHED, () => {
automationsDelegate.automationsFinished();
});
RNAutomations.subscribe();
}
}
exports.default = AutomationsInternal;
//# sourceMappingURL=AutomationsInternal.js.map