one
Version:
One is a React framework for web, iOS, and Android apps.
48 lines (45 loc) • 1.68 kB
JavaScript
import { validateCallback } from "../validateCallback.native.js";
import { Platform } from "react-native";
import { NitroModules } from "react-native-nitro-modules";
import { rethrowNativeError } from "../nativeError.native.js";
import { Purchases as Purchases$1 } from "./unavailable.native.js";
var hybrid;
function native() {
if (Platform.OS !== "ios") throw new Error("Purchases requires an iOS native build");
hybrid !== null && hybrid !== void 0 ? hybrid : hybrid = NitroModules.createHybridObject("OnePurchases");
return hybrid;
}
function getProducts(productIds) {
return native().getProducts(productIds).catch(rethrowNativeError);
}
function purchase(productId, appAccountToken) {
return native().purchase(productId, appAccountToken).catch(rethrowNativeError);
}
function getCurrentEntitlements() {
return native().getCurrentEntitlements().catch(rethrowNativeError);
}
function getUnfinishedTransactions() {
return native().getUnfinishedTransactions().catch(rethrowNativeError);
}
function finishTransaction(transactionId) {
return native().finishTransaction(transactionId).catch(rethrowNativeError);
}
function addTransactionListener(onUpdate) {
validateCallback(onUpdate, "Purchases.addTransactionListener requires a function");
return native().addTransactionListener(onUpdate);
}
function sync() {
return native().sync().catch(rethrowNativeError);
}
var nativePurchases = Object.freeze({
getProducts,
purchase,
getCurrentEntitlements,
getUnfinishedTransactions,
finishTransaction,
addTransactionListener,
sync
});
var Purchases = Platform.OS === "android" ? Purchases$1 : nativePurchases;
export { Purchases };
//# sourceMappingURL=index.native.js.map