expo-helium 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +5 -0
- package/README.md +139 -0
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/vcs-1/gc.properties +0 -0
- package/android/build.gradle +43 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/expo/modules/paywallsdk/HeliumPaywallSdkModule.kt +50 -0
- package/android/src/main/java/expo/modules/paywallsdk/HeliumPaywallSdkView.kt +30 -0
- package/build/HeliumPaywallSdk.types.d.ts +77 -0
- package/build/HeliumPaywallSdk.types.d.ts.map +1 -0
- package/build/HeliumPaywallSdk.types.js +12 -0
- package/build/HeliumPaywallSdk.types.js.map +1 -0
- package/build/HeliumPaywallSdkModule.d.ts +15 -0
- package/build/HeliumPaywallSdkModule.d.ts.map +1 -0
- package/build/HeliumPaywallSdkModule.js +4 -0
- package/build/HeliumPaywallSdkModule.js.map +1 -0
- package/build/HeliumPaywallSdkView.d.ts +4 -0
- package/build/HeliumPaywallSdkView.d.ts.map +1 -0
- package/build/HeliumPaywallSdkView.js +7 -0
- package/build/HeliumPaywallSdkView.js.map +1 -0
- package/build/index.d.ts +14 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +84 -0
- package/build/index.js.map +1 -0
- package/build/revenuecat/index.d.ts +2 -0
- package/build/revenuecat/index.d.ts.map +1 -0
- package/build/revenuecat/index.js +2 -0
- package/build/revenuecat/index.js.map +1 -0
- package/build/revenuecat/revenuecat.d.ts +16 -0
- package/build/revenuecat/revenuecat.d.ts.map +1 -0
- package/build/revenuecat/revenuecat.js +126 -0
- package/build/revenuecat/revenuecat.js.map +1 -0
- package/expo-module.config.json +9 -0
- package/ios/HeliumPaywallSdk.podspec +30 -0
- package/ios/HeliumPaywallSdkModule.swift +249 -0
- package/ios/HeliumPaywallSdkView.swift +38 -0
- package/package.json +55 -0
- package/src/HeliumPaywallSdk.types.ts +95 -0
- package/src/HeliumPaywallSdkModule.ts +36 -0
- package/src/HeliumPaywallSdkView.tsx +11 -0
- package/src/index.ts +113 -0
- package/src/revenuecat/index.ts +1 -0
- package/src/revenuecat/revenuecat.ts +136 -0
- package/tsconfig.json +9 -0
package/.eslintrc.js
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# helium-expo-sdk
|
|
2
|
+
|
|
3
|
+
## **Background**
|
|
4
|
+
|
|
5
|
+
Get set up with the Helium SDK for iOS in 5 minutes. Reach out over your Helium slack channel, or email [founders@tryhelium.com](mailto:founders@tryhelium.com) for any questions.
|
|
6
|
+
|
|
7
|
+
### Expo installation
|
|
8
|
+
|
|
9
|
+
Install the package by running:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx expo install expo-helium
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
We recommend using Expo 53 and up.
|
|
16
|
+
|
|
17
|
+
## **Configuration**
|
|
18
|
+
|
|
19
|
+
### Initialization
|
|
20
|
+
|
|
21
|
+
Initialize Helium by calling `initialize()` early in your app's lifecycle, typically in your root component.
|
|
22
|
+
`initialize` takes in a configuration object that includes your purchase config, event handlers, and other settings. (If you are using **RevenueCat**, skip to the next section.)
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
import { initialize, createCustomPurchaseConfig, HELIUM_CTA_NAMES } from 'expo-helium';
|
|
26
|
+
|
|
27
|
+
function App() {
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
initialize({
|
|
30
|
+
// Helium provided api key
|
|
31
|
+
apiKey: '<your-helium-api-key>',
|
|
32
|
+
|
|
33
|
+
// Custom user id - e.g. your amplitude analytics user id.
|
|
34
|
+
customUserId: '<your-custom-user-id>',
|
|
35
|
+
|
|
36
|
+
// Purchase configuration (see next section if using RevenueCat)
|
|
37
|
+
purchaseConfig: createCustomPurchaseConfig({
|
|
38
|
+
makePurchase: async (productId) => {
|
|
39
|
+
// Your purchase logic here
|
|
40
|
+
return { status: 'purchased' };
|
|
41
|
+
},
|
|
42
|
+
restorePurchases: async () => {
|
|
43
|
+
// Your restore logic here
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
}),
|
|
47
|
+
|
|
48
|
+
// Event handler for paywall events
|
|
49
|
+
onHeliumPaywallEvent: (event) => {
|
|
50
|
+
switch (event.type) {
|
|
51
|
+
case 'paywallOpen':
|
|
52
|
+
break;
|
|
53
|
+
case 'ctaPressed':
|
|
54
|
+
if (event.ctaName === HELIUM_CTA_NAMES.SCHEDULE_CALL) {
|
|
55
|
+
// Handle schedule call
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
case 'subscriptionSucceeded':
|
|
59
|
+
// Handle successful subscription
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
// Custom user traits
|
|
65
|
+
customUserTraits: {
|
|
66
|
+
"example_trait": "example_value",
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
});
|
|
70
|
+
}, []);
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### Use RevenueCat with Helium
|
|
75
|
+
|
|
76
|
+
**Important** Make sure that you've already:
|
|
77
|
+
|
|
78
|
+
- installed and configured RevenueCat's `Purchases` client - if not, follow [`https://www.revenuecat.com/docs/getting-started/configuring-sdk`](https://www.revenuecat.com/docs/getting-started/configuring-sdk) for more details.
|
|
79
|
+
- have packages configured for each apple app store SKU
|
|
80
|
+
- assigned one of your Offerings as "default"
|
|
81
|
+
- initialize RevenueCat (`Purchases.configure()`) _before_ initializing Helium
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import { createRevenueCatPurchaseConfig } from "expo-helium/revenuecat";
|
|
85
|
+
|
|
86
|
+
const asyncHeliumInit = async () => {
|
|
87
|
+
initialize({
|
|
88
|
+
apiKey: '<your-helium-api-key>',
|
|
89
|
+
customUserId: '<your-custom-user-id>',
|
|
90
|
+
purchaseConfig: createRevenueCatPurchaseConfig(),
|
|
91
|
+
onHeliumPaywallEvent: (event) => {
|
|
92
|
+
switch (event.type) {
|
|
93
|
+
case 'subscriptionFailed':
|
|
94
|
+
// Custom logic
|
|
95
|
+
break;
|
|
96
|
+
case 'subscriptionSucceeded':
|
|
97
|
+
// Handle a subscription success event
|
|
98
|
+
// e.g. navigate to a premium page
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
// RevenueCat ONLY: supply RevenueCat appUserId
|
|
103
|
+
// (and initialize RevenueCat before Helium initialize)
|
|
104
|
+
revenueCatAppUserId: await Purchases.getAppUserID()
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
void asyncHeliumInit();
|
|
110
|
+
}, []);
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## **Presenting Paywalls**
|
|
114
|
+
|
|
115
|
+
`presentUpsell` takes in a dictionary specifying the `triggerName` as well as an optional `onFallback` parameter defining custom fallback behavior (in case the user didn't have a network connection)
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { presentUpsell } from 'expo-helium';
|
|
119
|
+
|
|
120
|
+
function YourComponent() {
|
|
121
|
+
const handlePremiumPress = useCallback(async () => {
|
|
122
|
+
await presentUpsell({
|
|
123
|
+
triggerName: 'premium_feature_press',
|
|
124
|
+
onFallback: () => {
|
|
125
|
+
// Logic to open a default paywall
|
|
126
|
+
openFallbackPaywall();
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}, [presentUpsell]);
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<Button title="Try Premium" onPress={handlePremiumPress} />
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## **Paywall Events**
|
|
138
|
+
|
|
139
|
+
Helium emits various events during the lifecycle of a paywall. You can handle these events in your payment delegate. See the [Helium Events](https://docs.tryhelium.com/sdk/helium-events) for more details.
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
apply plugin: 'com.android.library'
|
|
2
|
+
|
|
3
|
+
group = 'expo.modules.paywallsdk'
|
|
4
|
+
version = '0.1.0'
|
|
5
|
+
|
|
6
|
+
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
7
|
+
apply from: expoModulesCorePlugin
|
|
8
|
+
applyKotlinExpoModulesCorePlugin()
|
|
9
|
+
useCoreDependencies()
|
|
10
|
+
useExpoPublishing()
|
|
11
|
+
|
|
12
|
+
// If you want to use the managed Android SDK versions from expo-modules-core, set this to true.
|
|
13
|
+
// The Android SDK versions will be bumped from time to time in SDK releases and may introduce breaking changes in your module code.
|
|
14
|
+
// Most of the time, you may like to manage the Android SDK versions yourself.
|
|
15
|
+
def useManagedAndroidSdkVersions = false
|
|
16
|
+
if (useManagedAndroidSdkVersions) {
|
|
17
|
+
useDefaultAndroidSdkVersions()
|
|
18
|
+
} else {
|
|
19
|
+
buildscript {
|
|
20
|
+
// Simple helper that allows the root project to override versions declared by this library.
|
|
21
|
+
ext.safeExtGet = { prop, fallback ->
|
|
22
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
project.android {
|
|
26
|
+
compileSdkVersion safeExtGet("compileSdkVersion", 34)
|
|
27
|
+
defaultConfig {
|
|
28
|
+
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
29
|
+
targetSdkVersion safeExtGet("targetSdkVersion", 34)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
android {
|
|
35
|
+
namespace "expo.modules.paywallsdk"
|
|
36
|
+
defaultConfig {
|
|
37
|
+
versionCode 1
|
|
38
|
+
versionName "0.1.0"
|
|
39
|
+
}
|
|
40
|
+
lintOptions {
|
|
41
|
+
abortOnError false
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
package expo.modules.paywallsdk
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.modules.Module
|
|
4
|
+
import expo.modules.kotlin.modules.ModuleDefinition
|
|
5
|
+
import java.net.URL
|
|
6
|
+
|
|
7
|
+
class HeliumPaywallSdkModule : Module() {
|
|
8
|
+
// Each module class must implement the definition function. The definition consists of components
|
|
9
|
+
// that describes the module's functionality and behavior.
|
|
10
|
+
// See https://docs.expo.dev/modules/module-api for more details about available components.
|
|
11
|
+
override fun definition() = ModuleDefinition {
|
|
12
|
+
// Sets the name of the module that JavaScript code will use to refer to the module. Takes a string as an argument.
|
|
13
|
+
// Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
|
|
14
|
+
// The module will be accessible from `requireNativeModule('HeliumPaywallSdk')` in JavaScript.
|
|
15
|
+
Name("HeliumPaywallSdk")
|
|
16
|
+
|
|
17
|
+
// Sets constant properties on the module. Can take a dictionary or a closure that returns a dictionary.
|
|
18
|
+
Constants(
|
|
19
|
+
"PI" to Math.PI
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
// Defines event names that the module can send to JavaScript.
|
|
23
|
+
Events("onChange")
|
|
24
|
+
|
|
25
|
+
// Defines a JavaScript synchronous function that runs the native code on the JavaScript thread.
|
|
26
|
+
Function("hello") {
|
|
27
|
+
"Hello world! 👋"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Defines a JavaScript function that always returns a Promise and whose native code
|
|
31
|
+
// is by default dispatched on the different thread than the JavaScript runtime runs on.
|
|
32
|
+
AsyncFunction("setValueAsync") { value: String ->
|
|
33
|
+
// Send an event to JavaScript.
|
|
34
|
+
sendEvent("onChange", mapOf(
|
|
35
|
+
"value" to value
|
|
36
|
+
))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Enables the module to be used as a native view. Definition components that are accepted as part of
|
|
40
|
+
// the view definition: Prop, Events.
|
|
41
|
+
View(HeliumPaywallSdkView::class) {
|
|
42
|
+
// Defines a setter for the `url` prop.
|
|
43
|
+
Prop("url") { view: HeliumPaywallSdkView, url: URL ->
|
|
44
|
+
view.webView.loadUrl(url.toString())
|
|
45
|
+
}
|
|
46
|
+
// Defines an event that the view can send to JavaScript.
|
|
47
|
+
Events("onLoad")
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
package expo.modules.paywallsdk
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.webkit.WebView
|
|
5
|
+
import android.webkit.WebViewClient
|
|
6
|
+
import expo.modules.kotlin.AppContext
|
|
7
|
+
import expo.modules.kotlin.viewevent.EventDispatcher
|
|
8
|
+
import expo.modules.kotlin.views.ExpoView
|
|
9
|
+
|
|
10
|
+
class HeliumPaywallSdkView(context: Context, appContext: AppContext) : ExpoView(context, appContext) {
|
|
11
|
+
// Creates and initializes an event dispatcher for the `onLoad` event.
|
|
12
|
+
// The name of the event is inferred from the value and needs to match the event name defined in the module.
|
|
13
|
+
private val onLoad by EventDispatcher()
|
|
14
|
+
|
|
15
|
+
// Defines a WebView that will be used as the root subview.
|
|
16
|
+
internal val webView = WebView(context).apply {
|
|
17
|
+
layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
|
|
18
|
+
webViewClient = object : WebViewClient() {
|
|
19
|
+
override fun onPageFinished(view: WebView, url: String) {
|
|
20
|
+
// Sends an event to JavaScript. Triggers a callback defined on the view component in JavaScript.
|
|
21
|
+
onLoad(mapOf("url" to url))
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
init {
|
|
27
|
+
// Adds the WebView to the view hierarchy.
|
|
28
|
+
addView(webView)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
export type OnLoadEventPayload = {
|
|
3
|
+
url: string;
|
|
4
|
+
};
|
|
5
|
+
export type HeliumPaywallSdkModuleEvents = {
|
|
6
|
+
onHeliumPaywallEvent: (params: HeliumPaywallEvent) => void;
|
|
7
|
+
onDelegateActionEvent: (params: DelegateActionEvent) => void;
|
|
8
|
+
};
|
|
9
|
+
export type HeliumPaywallEvent = {
|
|
10
|
+
type: string;
|
|
11
|
+
triggerName?: string;
|
|
12
|
+
paywallTemplateName?: string;
|
|
13
|
+
productKey?: string;
|
|
14
|
+
ctaName?: string;
|
|
15
|
+
configId?: string;
|
|
16
|
+
numAttempts?: number;
|
|
17
|
+
downloadTimeTakenMS?: number;
|
|
18
|
+
webviewRenderTimeTakenMS?: number;
|
|
19
|
+
imagesDownloadTimeTakenMS?: number;
|
|
20
|
+
fontsDownloadTimeTakenMS?: number;
|
|
21
|
+
bundleDownloadTimeMS?: number;
|
|
22
|
+
dismissAll?: boolean;
|
|
23
|
+
errorDescription?: string;
|
|
24
|
+
};
|
|
25
|
+
export type DelegateActionEvent = {
|
|
26
|
+
type: 'purchase' | 'restore';
|
|
27
|
+
productId?: string;
|
|
28
|
+
};
|
|
29
|
+
export type HeliumPaywallSdkViewProps = {
|
|
30
|
+
url: string;
|
|
31
|
+
onLoad: (event: {
|
|
32
|
+
nativeEvent: OnLoadEventPayload;
|
|
33
|
+
}) => void;
|
|
34
|
+
style?: StyleProp<ViewStyle>;
|
|
35
|
+
};
|
|
36
|
+
export type HeliumTransactionStatus = 'purchased' | 'failed' | 'cancelled' | 'pending' | 'restored';
|
|
37
|
+
export type HeliumPurchaseResult = {
|
|
38
|
+
status: HeliumTransactionStatus;
|
|
39
|
+
error?: string;
|
|
40
|
+
};
|
|
41
|
+
export type HeliumDownloadStatus = 'downloadSuccess' | 'downloadFailure' | 'inProgress' | 'notDownloadedYet';
|
|
42
|
+
/** Interface for providing custom purchase handling logic. */
|
|
43
|
+
export interface HeliumPurchaseConfig {
|
|
44
|
+
makePurchase: (productId: string) => Promise<HeliumPurchaseResult>;
|
|
45
|
+
restorePurchases: () => Promise<boolean>;
|
|
46
|
+
/** Optional RevenueCat API Key. If not provided, RevenueCat must be configured elsewhere. */
|
|
47
|
+
apiKey?: string;
|
|
48
|
+
}
|
|
49
|
+
export declare function createCustomPurchaseConfig(callbacks: {
|
|
50
|
+
makePurchase: (productId: string) => Promise<HeliumPurchaseResult>;
|
|
51
|
+
restorePurchases: () => Promise<boolean>;
|
|
52
|
+
}): HeliumPurchaseConfig;
|
|
53
|
+
export interface HeliumConfig {
|
|
54
|
+
/** Your Helium API Key */
|
|
55
|
+
apiKey: string;
|
|
56
|
+
/** Configuration for handling purchases. Can be custom functions or a pre-built handler config. */
|
|
57
|
+
purchaseConfig: HeliumPurchaseConfig;
|
|
58
|
+
/** Callback for receiving all Helium paywall events. */
|
|
59
|
+
onHeliumPaywallEvent: (event: HeliumPaywallEvent) => void;
|
|
60
|
+
triggers?: string[];
|
|
61
|
+
customUserId?: string;
|
|
62
|
+
customAPIEndpoint?: string;
|
|
63
|
+
customUserTraits?: Record<string, any>;
|
|
64
|
+
revenueCatAppUserId?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface NativeHeliumConfig {
|
|
67
|
+
apiKey: string;
|
|
68
|
+
customUserId?: string;
|
|
69
|
+
customAPIEndpoint?: string;
|
|
70
|
+
customUserTraits?: Record<string, any>;
|
|
71
|
+
revenueCatAppUserId?: string;
|
|
72
|
+
}
|
|
73
|
+
export declare const HELIUM_CTA_NAMES: {
|
|
74
|
+
SCHEDULE_CALL: string;
|
|
75
|
+
SUBSCRIBE_BUTTON: string;
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=HeliumPaywallSdk.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeliumPaywallSdk.types.d.ts","sourceRoot":"","sources":["../src/HeliumPaywallSdk.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG;IACzC,oBAAoB,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC3D,qBAAqB,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;CAC9D,CAAC;AACF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;IAC7B,SAAS,CAA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AC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,eAAO,MAAM,gBAAgB;;;CAG5B,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Helper function for creating Custom Purchase Config
|
|
2
|
+
export function createCustomPurchaseConfig(callbacks) {
|
|
3
|
+
return {
|
|
4
|
+
makePurchase: callbacks.makePurchase,
|
|
5
|
+
restorePurchases: callbacks.restorePurchases,
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export const HELIUM_CTA_NAMES = {
|
|
9
|
+
SCHEDULE_CALL: 'schedule_call',
|
|
10
|
+
SUBSCRIBE_BUTTON: 'subscribe_button',
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=HeliumPaywallSdk.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeliumPaywallSdk.types.js","sourceRoot":"","sources":["../src/HeliumPaywallSdk.types.ts"],"names":[],"mappings":"AAwDA,sDAAsD;AACtD,MAAM,UAAU,0BAA0B,CAAC,SAG1C;IACC,OAAO;QACL,YAAY,EAAE,SAAS,CAAC,YAAY;QACpC,gBAAgB,EAAE,SAAS,CAAC,gBAAgB;KAC7C,CAAC;AACJ,CAAC;AA0BD,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,aAAa,EAAE,eAAe;IAC9B,gBAAgB,EAAE,kBAAkB;CACrC,CAAA","sourcesContent":["import type { StyleProp, ViewStyle } from 'react-native';\n\nexport type OnLoadEventPayload = {\n url: string;\n};\n\nexport type HeliumPaywallSdkModuleEvents = {\n onHeliumPaywallEvent: (params: HeliumPaywallEvent) => void;\n onDelegateActionEvent: (params: DelegateActionEvent) => void;\n};\nexport type HeliumPaywallEvent = {\n type: string;\n triggerName?: string;\n paywallTemplateName?: string;\n productKey?: string;\n ctaName?: string;\n configId?: string;\n numAttempts?: number;\n downloadTimeTakenMS?: number;\n webviewRenderTimeTakenMS?: number;\n imagesDownloadTimeTakenMS?: number;\n fontsDownloadTimeTakenMS?: number;\n bundleDownloadTimeMS?: number;\n dismissAll?: boolean;\n errorDescription?: string;\n};\nexport type DelegateActionEvent = {\n type: 'purchase' | 'restore';\n productId?: string;\n};\n\nexport type HeliumPaywallSdkViewProps = {\n url: string;\n onLoad: (event: { nativeEvent: OnLoadEventPayload }) => void;\n style?: StyleProp<ViewStyle>;\n};\n\nexport type HeliumTransactionStatus = 'purchased' | 'failed' | 'cancelled' | 'pending' | 'restored';\nexport type HeliumPurchaseResult = {\n status: HeliumTransactionStatus;\n error?: string; // Optional error message\n};\nexport type HeliumDownloadStatus = 'downloadSuccess' | 'downloadFailure' | 'inProgress' | 'notDownloadedYet';\n\n// --- Purchase Configuration Types ---\n\n/** Interface for providing custom purchase handling logic. */\n\nexport interface HeliumPurchaseConfig {\n makePurchase: (productId: string) => Promise<HeliumPurchaseResult>;\n restorePurchases: () => Promise<boolean>;\n\n /** Optional RevenueCat API Key. If not provided, RevenueCat must be configured elsewhere. */\n apiKey?: string;\n}\n\n// Helper function for creating Custom Purchase Config\nexport function createCustomPurchaseConfig(callbacks: {\n makePurchase: (productId: string) => Promise<HeliumPurchaseResult>;\n restorePurchases: () => Promise<boolean>;\n}): HeliumPurchaseConfig {\n return {\n makePurchase: callbacks.makePurchase,\n restorePurchases: callbacks.restorePurchases,\n };\n}\n\nexport interface HeliumConfig {\n /** Your Helium API Key */\n apiKey: string;\n /** Configuration for handling purchases. Can be custom functions or a pre-built handler config. */\n purchaseConfig: HeliumPurchaseConfig;\n /** Callback for receiving all Helium paywall events. */\n onHeliumPaywallEvent: (event: HeliumPaywallEvent) => void; // Still mandatory\n\n // Optional configurations\n triggers?: string[];\n customUserId?: string;\n customAPIEndpoint?: string;\n customUserTraits?: Record<string, any>;\n revenueCatAppUserId?: string;\n}\n\nexport interface NativeHeliumConfig {\n apiKey: string;\n customUserId?: string;\n customAPIEndpoint?: string;\n customUserTraits?: Record<string, any>;\n revenueCatAppUserId?: string;\n}\n\nexport const HELIUM_CTA_NAMES = {\n SCHEDULE_CALL: 'schedule_call',\n SUBSCRIBE_BUTTON: 'subscribe_button',\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NativeModule } from "expo";
|
|
2
|
+
import { HeliumDownloadStatus, HeliumPaywallSdkModuleEvents, HeliumTransactionStatus, NativeHeliumConfig } from "./HeliumPaywallSdk.types";
|
|
3
|
+
declare class HeliumPaywallSdkModule extends NativeModule<HeliumPaywallSdkModuleEvents> {
|
|
4
|
+
initialize(config: NativeHeliumConfig): void;
|
|
5
|
+
presentUpsell(triggerName: string): void;
|
|
6
|
+
hideUpsell(): void;
|
|
7
|
+
hideAllUpsells(): void;
|
|
8
|
+
getDownloadStatus(): HeliumDownloadStatus;
|
|
9
|
+
fallbackOpenOrCloseEvent(trigger: string, isOpen: boolean, viewType: string): void;
|
|
10
|
+
handlePurchaseResult(statusString: HeliumTransactionStatus, errorMsg?: string): void;
|
|
11
|
+
handleRestoreResult(success: boolean): void;
|
|
12
|
+
}
|
|
13
|
+
declare const _default: HeliumPaywallSdkModule;
|
|
14
|
+
export default _default;
|
|
15
|
+
//# sourceMappingURL=HeliumPaywallSdkModule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeliumPaywallSdkModule.d.ts","sourceRoot":"","sources":["../src/HeliumPaywallSdkModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAC;AAEzD,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAC5B,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,OAAO,sBAAuB,SAAQ,YAAY,CAAC,4BAA4B,CAAC;IACrF,UAAU,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI;IAE5C,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAExC,UAAU,IAAI,IAAI;IAElB,cAAc,IAAI,IAAI;IAEtB,iBAAiB,IAAI,oBAAoB;IAEzC,wBAAwB,CACtB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,MAAM,GACf,IAAI;IAEP,oBAAoB,CAClB,YAAY,EAAE,uBAAuB,EACrC,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI;IAEP,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;CAC5C;;AAGD,wBAA+E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeliumPaywallSdkModule.js","sourceRoot":"","sources":["../src/HeliumPaywallSdkModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAkCzD,yDAAyD;AACzD,eAAe,mBAAmB,CAAyB,kBAAkB,CAAC,CAAC","sourcesContent":["import { NativeModule, requireNativeModule } from \"expo\";\n\nimport {\n HeliumDownloadStatus,\n HeliumPaywallSdkModuleEvents,\n HeliumTransactionStatus,\n NativeHeliumConfig,\n} from \"./HeliumPaywallSdk.types\";\n\ndeclare class HeliumPaywallSdkModule extends NativeModule<HeliumPaywallSdkModuleEvents> {\n initialize(config: NativeHeliumConfig): void;\n\n presentUpsell(triggerName: string): void;\n\n hideUpsell(): void;\n\n hideAllUpsells(): void;\n\n getDownloadStatus(): HeliumDownloadStatus;\n\n fallbackOpenOrCloseEvent(\n trigger: string,\n isOpen: boolean,\n viewType: string,\n ): void;\n\n handlePurchaseResult(\n statusString: HeliumTransactionStatus,\n errorMsg?: string,\n ): void;\n\n handleRestoreResult(success: boolean): void;\n}\n\n// This call loads the native module object from the JSI.\nexport default requireNativeModule<HeliumPaywallSdkModule>(\"HeliumPaywallSdk\");\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeliumPaywallSdkView.d.ts","sourceRoot":"","sources":["../src/HeliumPaywallSdkView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAKrE,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,qBAE5E"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { requireNativeView } from 'expo';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
const NativeView = requireNativeView('HeliumPaywallSdk');
|
|
4
|
+
export default function HeliumPaywallSdkView(props) {
|
|
5
|
+
return <NativeView {...props}/>;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=HeliumPaywallSdkView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeliumPaywallSdkView.js","sourceRoot":"","sources":["../src/HeliumPaywallSdkView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,UAAU,GACd,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;AAExC,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,KAAgC;IAC3E,OAAO,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,EAAG,CAAC;AACnC,CAAC","sourcesContent":["import { requireNativeView } from 'expo';\nimport * as React from 'react';\n\nimport { HeliumPaywallSdkViewProps } from './HeliumPaywallSdk.types';\n\nconst NativeView: React.ComponentType<HeliumPaywallSdkViewProps> =\n requireNativeView('HeliumPaywallSdk');\n\nexport default function HeliumPaywallSdkView(props: HeliumPaywallSdkViewProps) {\n return <NativeView {...props} />;\n}\n"]}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HeliumConfig } from "./HeliumPaywallSdk.types";
|
|
2
|
+
export { default } from './HeliumPaywallSdkModule';
|
|
3
|
+
export * from './HeliumPaywallSdk.types';
|
|
4
|
+
export declare const initialize: (config: HeliumConfig) => void;
|
|
5
|
+
export declare const presentUpsell: ({ triggerName, onFallback }: {
|
|
6
|
+
triggerName: string;
|
|
7
|
+
onFallback?: () => void;
|
|
8
|
+
}) => void;
|
|
9
|
+
export declare const hideUpsell: () => void;
|
|
10
|
+
export declare const hideAllUpsells: () => void;
|
|
11
|
+
export declare const getDownloadStatus: () => import("./HeliumPaywallSdk.types").HeliumDownloadStatus;
|
|
12
|
+
export { createCustomPurchaseConfig, HELIUM_CTA_NAMES } from './HeliumPaywallSdk.types';
|
|
13
|
+
export type { HeliumTransactionStatus, HeliumConfig, } from './HeliumPaywallSdk.types';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EAGb,MAAM,0BAA0B,CAAC;AAIlC,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD,cAAe,0BAA0B,CAAC;AAW1C,eAAO,MAAM,UAAU,GAAI,QAAQ,YAAY,SAmD9C,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,6BAGG;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;CACzB,SAoBA,CAAC;AAEF,eAAO,MAAM,UAAU,YAAoC,CAAC;AAC5D,eAAO,MAAM,cAAc,YAAwC,CAAC;AACpE,eAAO,MAAM,iBAAiB,+DAA2C,CAAC;AAE1E,OAAO,EAAC,0BAA0B,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAEtF,YAAY,EACV,uBAAuB,EACvB,YAAY,GACb,MAAM,0BAA0B,CAAC"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import HeliumPaywallSdkModule from "./HeliumPaywallSdkModule";
|
|
2
|
+
export { default } from './HeliumPaywallSdkModule';
|
|
3
|
+
// export { default as HeliumPaywallSdkView } from './HeliumPaywallSdkView';
|
|
4
|
+
export * from './HeliumPaywallSdk.types';
|
|
5
|
+
function addHeliumPaywallEventListener(listener) {
|
|
6
|
+
return HeliumPaywallSdkModule.addListener('onHeliumPaywallEvent', listener);
|
|
7
|
+
}
|
|
8
|
+
function addDelegateActionEventListener(listener) {
|
|
9
|
+
return HeliumPaywallSdkModule.addListener('onDelegateActionEvent', listener);
|
|
10
|
+
}
|
|
11
|
+
let isInitialized = false;
|
|
12
|
+
export const initialize = (config) => {
|
|
13
|
+
if (isInitialized) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
isInitialized = true;
|
|
17
|
+
HeliumPaywallSdkModule.removeAllListeners('onHeliumPaywallEvent');
|
|
18
|
+
HeliumPaywallSdkModule.removeAllListeners('onDelegateActionEvent');
|
|
19
|
+
// Set up listener for paywall events
|
|
20
|
+
addHeliumPaywallEventListener((event) => {
|
|
21
|
+
config.onHeliumPaywallEvent(event);
|
|
22
|
+
});
|
|
23
|
+
// Set up delegate action listener for purchase and restore operations
|
|
24
|
+
addDelegateActionEventListener(async (event) => {
|
|
25
|
+
try {
|
|
26
|
+
if (event.type === 'purchase') {
|
|
27
|
+
if (event.productId) {
|
|
28
|
+
const result = await config.purchaseConfig.makePurchase(event.productId);
|
|
29
|
+
HeliumPaywallSdkModule.handlePurchaseResult(result.status, result.error);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
HeliumPaywallSdkModule.handlePurchaseResult('failed', 'No product ID for purchase event.');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
else if (event.type === 'restore') {
|
|
36
|
+
const success = await config.purchaseConfig.restorePurchases();
|
|
37
|
+
HeliumPaywallSdkModule.handleRestoreResult(success);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
// Send failure result based on action type
|
|
42
|
+
if (event.type === 'purchase') {
|
|
43
|
+
console.log('[Helium] Unexpected error: ', error);
|
|
44
|
+
HeliumPaywallSdkModule.handlePurchaseResult('failed');
|
|
45
|
+
}
|
|
46
|
+
else if (event.type === 'restore') {
|
|
47
|
+
HeliumPaywallSdkModule.handleRestoreResult(false);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
// Create native config object
|
|
52
|
+
const nativeConfig = {
|
|
53
|
+
apiKey: config.apiKey,
|
|
54
|
+
customUserId: config.customUserId,
|
|
55
|
+
customAPIEndpoint: config.customAPIEndpoint,
|
|
56
|
+
customUserTraits: config.customUserTraits,
|
|
57
|
+
revenueCatAppUserId: config.revenueCatAppUserId
|
|
58
|
+
};
|
|
59
|
+
// Initialize the native module
|
|
60
|
+
HeliumPaywallSdkModule.initialize(nativeConfig);
|
|
61
|
+
};
|
|
62
|
+
export const presentUpsell = ({ triggerName, onFallback }) => {
|
|
63
|
+
// todo check HeliumBridge.getFetchedTriggerNames((triggerNames: string[]) ??
|
|
64
|
+
const downloadStatus = getDownloadStatus();
|
|
65
|
+
if (downloadStatus !== 'downloadSuccess') {
|
|
66
|
+
console.log(`Helium trigger "${triggerName}" not found or download status not successful. Status:`, downloadStatus);
|
|
67
|
+
onFallback?.();
|
|
68
|
+
HeliumPaywallSdkModule.fallbackOpenOrCloseEvent(triggerName, true, 'presented');
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
HeliumPaywallSdkModule.presentUpsell(triggerName);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
console.log('Helium present error', error);
|
|
76
|
+
onFallback?.();
|
|
77
|
+
HeliumPaywallSdkModule.fallbackOpenOrCloseEvent(triggerName, true, 'presented');
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
export const hideUpsell = HeliumPaywallSdkModule.hideUpsell;
|
|
81
|
+
export const hideAllUpsells = HeliumPaywallSdkModule.hideAllUpsells;
|
|
82
|
+
export const getDownloadStatus = HeliumPaywallSdkModule.getDownloadStatus;
|
|
83
|
+
export { createCustomPurchaseConfig, HELIUM_CTA_NAMES } from './HeliumPaywallSdk.types';
|
|
84
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,sBAAsB,MAAM,0BAA0B,CAAC;AAG9D,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,4EAA4E;AAC5E,cAAe,0BAA0B,CAAC;AAE1C,SAAS,6BAA6B,CAAC,QAA6C;IAClF,OAAO,sBAAsB,CAAC,WAAW,CAAC,sBAAsB,EAAE,QAAQ,CAAC,CAAC;AAC9E,CAAC;AAED,SAAS,8BAA8B,CAAC,QAA8C;IACpF,OAAO,sBAAsB,CAAC,WAAW,CAAC,uBAAuB,EAAE,QAAQ,CAAC,CAAC;AAC/E,CAAC;AAED,IAAI,aAAa,GAAG,KAAK,CAAC;AAC1B,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAoB,EAAE,EAAE;IACjD,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO;IACT,CAAC;IACD,aAAa,GAAG,IAAI,CAAC;IAErB,sBAAsB,CAAC,kBAAkB,CAAC,sBAAsB,CAAC,CAAC;IAClE,sBAAsB,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,CAAC;IAEnE,qCAAqC;IACrC,6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AC,MAAM,0BAA0B,CAAC","sourcesContent":["import {\n DelegateActionEvent,\n HeliumConfig,\n HeliumPaywallEvent,\n NativeHeliumConfig,\n} from \"./HeliumPaywallSdk.types\";\nimport HeliumPaywallSdkModule from \"./HeliumPaywallSdkModule\";\nimport { EventSubscription } from 'expo-modules-core';\n\nexport { default } from './HeliumPaywallSdkModule';\n// export { default as HeliumPaywallSdkView } from './HeliumPaywallSdkView';\nexport * from './HeliumPaywallSdk.types';\n\nfunction addHeliumPaywallEventListener(listener: (event: HeliumPaywallEvent) => void): EventSubscription {\n return HeliumPaywallSdkModule.addListener('onHeliumPaywallEvent', listener);\n}\n\nfunction addDelegateActionEventListener(listener: (event: DelegateActionEvent) => void): EventSubscription {\n return HeliumPaywallSdkModule.addListener('onDelegateActionEvent', listener);\n}\n\nlet isInitialized = false;\nexport const initialize = (config: HeliumConfig) => {\n if (isInitialized) {\n return;\n }\n isInitialized = true;\n\n HeliumPaywallSdkModule.removeAllListeners('onHeliumPaywallEvent');\n HeliumPaywallSdkModule.removeAllListeners('onDelegateActionEvent');\n\n // Set up listener for paywall events\n addHeliumPaywallEventListener((event) => {\n config.onHeliumPaywallEvent(event);\n });\n\n // Set up delegate action listener for purchase and restore operations\n addDelegateActionEventListener(async (event) => {\n try {\n if (event.type === 'purchase') {\n if (event.productId) {\n const result = await config.purchaseConfig.makePurchase(event.productId);\n HeliumPaywallSdkModule.handlePurchaseResult(result.status, result.error);\n } else {\n HeliumPaywallSdkModule.handlePurchaseResult('failed', 'No product ID for purchase event.');\n }\n }\n else if (event.type === 'restore') {\n const success = await config.purchaseConfig.restorePurchases();\n HeliumPaywallSdkModule.handleRestoreResult(success);\n }\n } catch (error) {\n // Send failure result based on action type\n if (event.type === 'purchase') {\n console.log('[Helium] Unexpected error: ', error);\n HeliumPaywallSdkModule.handlePurchaseResult('failed');\n } else if (event.type === 'restore') {\n HeliumPaywallSdkModule.handleRestoreResult(false);\n }\n }\n });\n\n // Create native config object\n const nativeConfig: NativeHeliumConfig = {\n apiKey: config.apiKey,\n customUserId: config.customUserId,\n customAPIEndpoint: config.customAPIEndpoint,\n customUserTraits: config.customUserTraits,\n revenueCatAppUserId: config.revenueCatAppUserId\n };\n\n // Initialize the native module\n HeliumPaywallSdkModule.initialize(nativeConfig);\n};\n\nexport const presentUpsell = ({\n triggerName,\n onFallback\n }: {\n triggerName: string;\n onFallback?: () => void;\n}) => {\n // todo check HeliumBridge.getFetchedTriggerNames((triggerNames: string[]) ??\n const downloadStatus = getDownloadStatus();\n if (downloadStatus !== 'downloadSuccess') {\n console.log(\n `Helium trigger \"${triggerName}\" not found or download status not successful. Status:`,\n downloadStatus\n );\n onFallback?.();\n HeliumPaywallSdkModule.fallbackOpenOrCloseEvent(triggerName, true, 'presented');\n return;\n }\n\n try {\n HeliumPaywallSdkModule.presentUpsell(triggerName);\n } catch (error) {\n console.log('Helium present error', error);\n onFallback?.();\n HeliumPaywallSdkModule.fallbackOpenOrCloseEvent(triggerName, true, 'presented');\n }\n};\n\nexport const hideUpsell = HeliumPaywallSdkModule.hideUpsell;\nexport const hideAllUpsells = HeliumPaywallSdkModule.hideAllUpsells;\nexport const getDownloadStatus = HeliumPaywallSdkModule.getDownloadStatus;\n\nexport {createCustomPurchaseConfig, HELIUM_CTA_NAMES} from './HeliumPaywallSdk.types';\n\nexport type {\n HeliumTransactionStatus,\n HeliumConfig,\n} from './HeliumPaywallSdk.types';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/revenuecat/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/revenuecat/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { createRevenueCatPurchaseConfig } from \"./revenuecat\";\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { HeliumPurchaseConfig, HeliumPurchaseResult } from "../HeliumPaywallSdk.types";
|
|
2
|
+
export declare function createRevenueCatPurchaseConfig(config?: {
|
|
3
|
+
apiKey?: string;
|
|
4
|
+
}): HeliumPurchaseConfig;
|
|
5
|
+
export declare class RevenueCatHeliumHandler {
|
|
6
|
+
private productIdToPackageMapping;
|
|
7
|
+
private isMappingInitialized;
|
|
8
|
+
private initializationPromise;
|
|
9
|
+
constructor(apiKey?: string);
|
|
10
|
+
private initializePackageMapping;
|
|
11
|
+
private ensureMappingInitialized;
|
|
12
|
+
makePurchase(productId: string): Promise<HeliumPurchaseResult>;
|
|
13
|
+
private isProductActive;
|
|
14
|
+
restorePurchases(): Promise<boolean>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=revenuecat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revenuecat.d.ts","sourceRoot":"","sources":["../../src/revenuecat/revenuecat.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,oBAAoB,EAAE,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAGrF,wBAAgB,8BAA8B,CAAC,MAAM,CAAC,EAAE;IACtD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,oBAAoB,CAOvB;AAED,qBAAa,uBAAuB;IAChC,OAAO,CAAC,yBAAyB,CAAwC;IACzE,OAAO,CAAC,oBAAoB,CAAkB;IAC9C,OAAO,CAAC,qBAAqB,CAA8B;gBAE/C,MAAM,CAAC,EAAE,MAAM;YAQb,wBAAwB;YAyBxB,wBAAwB;IAQhC,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IA0DpE,OAAO,CAAC,eAAe;IAMjB,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC;CAS7C"}
|