Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions react-native-purchases-ui/src/preview/nativeModules.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PurchasesCommon } from "@revenuecat/purchases-js-hybrid-mappings"
import { PAYWALL_RESULT } from "@revenuecat/purchases-typescript-internal"

/**
Expand All @@ -6,12 +7,30 @@ import { PAYWALL_RESULT } from "@revenuecat/purchases-typescript-internal"
*/
export const previewNativeModuleRNPaywalls = {

presentPaywall: () => {
return PAYWALL_RESULT.NOT_PRESENTED
presentPaywall: async (
offeringIdentifier?: string,
presentedOfferingContext?: Record<string, unknown>,
_displayCloseButton?: boolean,
_fontFamily?: string | null,
Comment on lines +13 to +14
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two are unused. Is it intentional to avoid breaking the API in the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is basically called from the shared code, and these parameters are sent. I mostly prefer to have them so we know they exist, but are unused currently.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Makes total sense!

): Promise<PAYWALL_RESULT> => {
return await PurchasesCommon.getInstance().presentPaywall({
offeringIdentifier,
presentedOfferingContext,
}) as PAYWALL_RESULT;
},

presentPaywallIfNeeded: () => {
return PAYWALL_RESULT.NOT_PRESENTED
presentPaywallIfNeeded: async (
requiredEntitlementIdentifier: string,
offeringIdentifier?: string,
presentedOfferingContext?: Record<string, unknown>,
_displayCloseButton?: boolean,
_fontFamily?: string | null,
) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to return a Promise<PAYWALL_RESULT> in this method as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, we should 👍

return await PurchasesCommon.getInstance().presentPaywall({
requiredEntitlementIdentifier,
offeringIdentifier,
presentedOfferingContext,
}) as PAYWALL_RESULT;
},

}
Expand Down
2 changes: 1 addition & 1 deletion react-native-purchases-ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"lib": ["esnext"],
"lib": ["esnext", "dom"],
"module": "esnext",
"moduleResolution": "node",
"noFallthroughCasesInSwitch": true,
Expand Down