\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
49 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
50 |
51 | [lints]
52 | sketchy-null-number=warn
53 | sketchy-null-mixed=warn
54 | sketchy-number=warn
55 | untyped-type-import=warn
56 | nonstrict-import=warn
57 | deprecated-type=warn
58 | unsafe-getters-setters=warn
59 | inexact-spread=warn
60 | unnecessary-invariant=warn
61 | signature-verification-failure=warn
62 | deprecated-utility=error
63 |
64 | [strict]
65 | deprecated-type
66 | nonstrict-import
67 | sketchy-null
68 | unclear-type
69 | unsafe-getters-setters
70 | untyped-import
71 | untyped-type-import
72 |
73 | [version]
74 | ^0.113.0
75 |
--------------------------------------------------------------------------------
/example/.gitattributes:
--------------------------------------------------------------------------------
1 | *.pbxproj -text
2 |
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | # OSX
2 | #
3 | .DS_Store
4 |
5 | # Xcode
6 | #
7 | build/
8 | *.pbxuser
9 | !default.pbxuser
10 | *.mode1v3
11 | !default.mode1v3
12 | *.mode2v3
13 | !default.mode2v3
14 | *.perspectivev3
15 | !default.perspectivev3
16 | xcuserdata
17 | *.xccheckout
18 | *.moved-aside
19 | DerivedData
20 | *.hmap
21 | *.ipa
22 | *.xcuserstate
23 |
24 | # Android/IntelliJ
25 | #
26 | build/
27 | .idea
28 | .gradle
29 | local.properties
30 | *.iml
31 |
32 | # node.js
33 | #
34 | node_modules/
35 | npm-debug.log
36 | yarn-error.log
37 |
38 | # BUCK
39 | buck-out/
40 | \.buckd/
41 | *.keystore
42 | !debug.keystore
43 |
44 | # fastlane
45 | #
46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
47 | # screenshots whenever they are needed.
48 | # For more information about the recommended setup visit:
49 | # https://docs.fastlane.tools/best-practices/source-control/
50 |
51 | */fastlane/report.xml
52 | */fastlane/Preview.html
53 | */fastlane/screenshots
54 |
55 | # Bundle artifact
56 | *.jsbundle
57 |
58 | # CocoaPods
59 | /ios/Pods/
60 |
--------------------------------------------------------------------------------
/example/.prettierrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | bracketSpacing: false,
3 | jsxBracketSameLine: true,
4 | singleQuote: true,
5 | trailingComma: 'all',
6 | };
7 |
--------------------------------------------------------------------------------
/example/.watchmanconfig:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/example/__tests__/App-test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @format
3 | */
4 |
5 | import 'react-native';
6 | import React from 'react';
7 | import App from '../App';
8 |
9 | // Note: test renderer must be required after react-native.
10 | import renderer from 'react-test-renderer';
11 |
12 | it('renders correctly', () => {
13 | renderer.create( );
14 | });
15 |
--------------------------------------------------------------------------------
/example/android/app/_BUCK:
--------------------------------------------------------------------------------
1 | # To learn about Buck see [Docs](https://buckbuild.com/).
2 | # To run your application with Buck:
3 | # - install Buck
4 | # - `npm start` - to start the packager
5 | # - `cd android`
6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
8 | # - `buck install -r android/app` - compile, install and run application
9 | #
10 |
11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
12 |
13 | lib_deps = []
14 |
15 | create_aar_targets(glob(["libs/*.aar"]))
16 |
17 | create_jar_targets(glob(["libs/*.jar"]))
18 |
19 | android_library(
20 | name = "all-libs",
21 | exported_deps = lib_deps,
22 | )
23 |
24 | android_library(
25 | name = "app-code",
26 | srcs = glob([
27 | "src/main/java/**/*.java",
28 | ]),
29 | deps = [
30 | ":all-libs",
31 | ":build_config",
32 | ":res",
33 | ],
34 | )
35 |
36 | android_build_config(
37 | name = "build_config",
38 | package = "com.qonversion.sample",
39 | )
40 |
41 | android_resource(
42 | name = "res",
43 | package = "com.qonversion.sample",
44 | res = "src/main/res",
45 | )
46 |
47 | android_binary(
48 | name = "app",
49 | keystore = "//android/keystores:debug",
50 | manifest = "src/main/AndroidManifest.xml",
51 | package_type = "debug",
52 | deps = [
53 | ":app-code",
54 | ],
55 | )
56 |
--------------------------------------------------------------------------------
/example/android/app/build_defs.bzl:
--------------------------------------------------------------------------------
1 | """Helper definitions to glob .aar and .jar targets"""
2 |
3 | def create_aar_targets(aarfiles):
4 | for aarfile in aarfiles:
5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
6 | lib_deps.append(":" + name)
7 | android_prebuilt_aar(
8 | name = name,
9 | aar = aarfile,
10 | )
11 |
12 | def create_jar_targets(jarfiles):
13 | for jarfile in jarfiles:
14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
15 | lib_deps.append(":" + name)
16 | prebuilt_jar(
17 | name = name,
18 | binary_jar = jarfile,
19 | )
20 |
--------------------------------------------------------------------------------
/example/android/app/debug.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qonversion/react-native-sdk/a5789cd150e97b4a03a7eeb52b296412468e2d80/example/android/app/debug.keystore
--------------------------------------------------------------------------------
/example/android/app/google-services.json:
--------------------------------------------------------------------------------
1 | {
2 | "project_info": {
3 | "project_number": "202024918040",
4 | "project_id": "qonversion-rn-sample-app",
5 | "storage_bucket": "qonversion-rn-sample-app.appspot.com"
6 | },
7 | "client": [
8 | {
9 | "client_info": {
10 | "mobilesdk_app_id": "1:202024918040:android:2d8bcc6554f277ba6c776d",
11 | "android_client_info": {
12 | "package_name": "com.qonversion.sample"
13 | }
14 | },
15 | "oauth_client": [
16 | {
17 | "client_id": "202024918040-esh8gte7gai0dcatgh060k8fp6g7l4iu.apps.googleusercontent.com",
18 | "client_type": 3
19 | }
20 | ],
21 | "api_key": [
22 | {
23 | "current_key": "AIzaSyDaSqu-P0IZJdjGhmhiuYfYq8OsN89yMtk"
24 | }
25 | ],
26 | "services": {
27 | "appinvite_service": {
28 | "other_platform_oauth_client": [
29 | {
30 | "client_id": "202024918040-esh8gte7gai0dcatgh060k8fp6g7l4iu.apps.googleusercontent.com",
31 | "client_type": 3
32 | }
33 | ]
34 | }
35 | }
36 | }
37 | ],
38 | "configuration_version": "1"
39 | }
--------------------------------------------------------------------------------
/example/android/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
--------------------------------------------------------------------------------
/example/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/android/app/src/debug/java/com/qonversion/sample/ReactNativeFlipper.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Facebook, Inc. and its affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the LICENSE file in the root
5 | * directory of this source tree.
6 | */
7 | package com.qonversion.sample;
8 |
9 | import android.content.Context;
10 | import com.facebook.flipper.android.AndroidFlipperClient;
11 | import com.facebook.flipper.android.utils.FlipperUtils;
12 | import com.facebook.flipper.core.FlipperClient;
13 | import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
14 | import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
15 | import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
16 | import com.facebook.flipper.plugins.inspector.DescriptorMapping;
17 | import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
18 | import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
19 | import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
20 | import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
21 | import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
22 | import com.facebook.react.ReactInstanceManager;
23 | import com.facebook.react.bridge.ReactContext;
24 | import com.facebook.react.modules.network.NetworkingModule;
25 | import okhttp3.OkHttpClient;
26 |
27 | public class ReactNativeFlipper {
28 | public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
29 | if (FlipperUtils.shouldEnableFlipper(context)) {
30 | final FlipperClient client = AndroidFlipperClient.getInstance(context);
31 |
32 | client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
33 | client.addPlugin(new ReactFlipperPlugin());
34 | client.addPlugin(new DatabasesFlipperPlugin(context));
35 | client.addPlugin(new SharedPreferencesFlipperPlugin(context));
36 | client.addPlugin(CrashReporterPlugin.getInstance());
37 |
38 | NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
39 | NetworkingModule.setCustomClientBuilder(
40 | new NetworkingModule.CustomClientBuilder() {
41 | @Override
42 | public void apply(OkHttpClient.Builder builder) {
43 | builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
44 | }
45 | });
46 | client.addPlugin(networkFlipperPlugin);
47 | client.start();
48 |
49 | // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
50 | // Hence we run if after all native modules have been initialized
51 | ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
52 | if (reactContext == null) {
53 | reactInstanceManager.addReactInstanceEventListener(
54 | new ReactInstanceManager.ReactInstanceEventListener() {
55 | @Override
56 | public void onReactContextInitialized(ReactContext reactContext) {
57 | reactInstanceManager.removeReactInstanceEventListener(this);
58 | reactContext.runOnNativeModulesQueueThread(
59 | new Runnable() {
60 | @Override
61 | public void run() {
62 | client.addPlugin(new FrescoFlipperPlugin());
63 | }
64 | });
65 | }
66 | });
67 | } else {
68 | client.addPlugin(new FrescoFlipperPlugin());
69 | }
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/example/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
16 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
31 |
32 |
34 |
35 |
36 |
37 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/example/android/app/src/main/assets/qonversion_android_fallbacks.json:
--------------------------------------------------------------------------------
1 | {
2 | "products": [
3 | {
4 | "id": "android_installment",
5 | "duration": 1,
6 | "store_id": "gb7_test_subscription",
7 | "type": 1,
8 | "base_plan_id": "monthly-installment"
9 | },
10 | {
11 | "id": "android_prepaid_2",
12 | "duration": null,
13 | "store_id": "daniel_prepaid",
14 | "type": 1,
15 | "base_plan_id": "monthly"
16 | },
17 | {
18 | "id": "dan_test",
19 | "duration": null,
20 | "store_id": "dan_test_annual",
21 | "type": null
22 | },
23 | {
24 | "id": "gb6_annual",
25 | "duration": 4,
26 | "store_id": "gb6_test",
27 | "type": 0,
28 | "base_plan_id": "annual"
29 | },
30 | {
31 | "id": "gb6_monthly",
32 | "duration": 1,
33 | "store_id": "gb6_test",
34 | "type": 0,
35 | "base_plan_id": "monthly"
36 | },
37 | {
38 | "id": "gb6_weekly",
39 | "duration": 0,
40 | "store_id": "gb6_test",
41 | "type": 1,
42 | "base_plan_id": "weekly"
43 | },
44 | {
45 | "id": "android_prepaid",
46 | "duration": 2,
47 | "store_id": "gp5_test_subscription_4",
48 | "type": 1,
49 | "base_plan_id": "prepaid-3m"
50 | },
51 | {
52 | "id": "weekly",
53 | "duration": 0,
54 | "store_id": "gp5_test_subscription_4",
55 | "type": 1,
56 | "base_plan_id": "monthly-2"
57 | },
58 | {
59 | "id": "consumable",
60 | "duration": null,
61 | "store_id": "qonversion_inapp_sample",
62 | "type": 2
63 | },
64 | {
65 | "id": "subs_plus_trial",
66 | "duration": 1,
67 | "store_id": "gp5_test_subscription_4",
68 | "type": 0
69 | },
70 | {
71 | "id": "annual",
72 | "duration": 4,
73 | "store_id": "article_test_trial",
74 | "type": 0
75 | },
76 | {
77 | "id": "in_app",
78 | "duration": null,
79 | "store_id": "qonversion_sample_purchase",
80 | "type": 2
81 | }
82 | ],
83 | "offerings": [
84 | {
85 | "id": "main",
86 | "tag": 1,
87 | "products": [
88 | {
89 | "id": "weekly",
90 | "duration": 0,
91 | "store_id": "gp5_test_subscription_4",
92 | "type": 1,
93 | "base_plan_id": "monthly-2"
94 | },
95 | {
96 | "id": "annual",
97 | "duration": 4,
98 | "store_id": "article_test_trial",
99 | "type": 0
100 | },
101 | {
102 | "id": "consumable",
103 | "duration": null,
104 | "store_id": "qonversion_inapp_sample",
105 | "type": 2
106 | }
107 | ]
108 | },
109 | {
110 | "id": "discounted_offer",
111 | "tag": 0,
112 | "products": []
113 | }
114 | ],
115 | "products_permissions": {
116 | "android_installment": [
117 | "standart"
118 | ],
119 | "android_prepaid_2": [
120 | "premium"
121 | ],
122 | "dan_test": [
123 | "test_permission"
124 | ],
125 | "gb6_annual": [
126 | "premium"
127 | ],
128 | "gb6_monthly": [
129 | "plus"
130 | ],
131 | "gb6_weekly": [
132 | "standart"
133 | ],
134 | "android_prepaid": [
135 | "premium"
136 | ],
137 | "weekly": [
138 | "plus"
139 | ],
140 | "consumable": [],
141 | "subs_plus_trial": [
142 | "standart"
143 | ],
144 | "annual": [
145 | "standart",
146 | "sample"
147 | ],
148 | "in_app": [
149 | "Premium Movies"
150 | ]
151 | },
152 | "remote_config_list": [
153 | {
154 | "experiment": null,
155 | "payload": {
156 | "CTA": "Start Trial",
157 | "CTA_color": "#307BF6",
158 | "main_image": "[IMAGE_URL]",
159 | "product_id": "prod_7d_trial_5.99",
160 | "show_close_button": true
161 | },
162 | "source": {
163 | "assignment_type": "auto",
164 | "context_key": "main_paywall",
165 | "name": "default paywall",
166 | "type": "remote_configuration",
167 | "uid": "0dcb1bd9-9bc3-4668-84aa-4540d1042c5d"
168 | }
169 | },
170 | {
171 | "experiment": null,
172 | "payload": {
173 | "CTA": "Start you trial",
174 | "CTA_color": "red",
175 | "main_image": "111",
176 | "product_id": "123123123123123",
177 | "show_close_button": true
178 | },
179 | "source": {
180 | "assignment_type": "auto",
181 | "context_key": "trulala",
182 | "name": "Default settings",
183 | "type": "remote_configuration",
184 | "uid": "12feb1dd-8096-47bc-a5a1-443fd2828ecc"
185 | }
186 | },
187 | {
188 | "experiment": null,
189 | "payload": {
190 | "test_key": "test_value"
191 | },
192 | "source": {
193 | "assignment_type": "auto",
194 | "context_key": "test_context_key",
195 | "name": "Test with context key1",
196 | "type": "remote_configuration",
197 | "uid": "c5077ec4-acf4-41ea-8b43-05114be5d7ce"
198 | }
199 | },
200 | {
201 | "experiment": null,
202 | "payload": {
203 | "test_key_2": "test_value_2"
204 | },
205 | "source": {
206 | "assignment_type": "auto",
207 | "context_key": "test_context_key_2",
208 | "name": "Test with context key2 - copy",
209 | "type": "remote_configuration",
210 | "uid": "1c000f2a-2f4b-4736-b5dd-75b13bf73deb"
211 | }
212 | },
213 | {
214 | "experiment": null,
215 | "payload": {
216 | "bool": true,
217 | "json": {
218 | "key": "value"
219 | }
220 | },
221 | "source": {
222 | "assignment_type": "auto",
223 | "context_key": "swift_key ",
224 | "name": "Swift",
225 | "type": "remote_configuration",
226 | "uid": "9f85d738-56d8-4f6c-b54a-c08658be2cb4"
227 | }
228 | }
229 | ]
230 | }
--------------------------------------------------------------------------------
/example/android/app/src/main/java/com/qonversion/sample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.qonversion.sample;
2 |
3 | import com.facebook.react.ReactActivity;
4 |
5 | public class MainActivity extends ReactActivity {
6 |
7 | /**
8 | * Returns the name of the main component registered from JavaScript. This is used to schedule
9 | * rendering of the component.
10 | */
11 | @Override
12 | protected String getMainComponentName() {
13 | return "example";
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/com/qonversion/sample/MainApplication.java:
--------------------------------------------------------------------------------
1 | package com.qonversion.sample;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 | import com.facebook.react.PackageList;
6 | import com.facebook.react.ReactApplication;
7 | import com.facebook.react.ReactInstanceManager;
8 | import com.facebook.react.ReactNativeHost;
9 | import com.facebook.react.ReactPackage;
10 | import com.facebook.soloader.SoLoader;
11 | import com.qonversion.sample.BuildConfig;
12 |
13 | import java.lang.reflect.InvocationTargetException;
14 | import java.util.List;
15 |
16 | public class MainApplication extends Application implements ReactApplication {
17 |
18 | private final ReactNativeHost mReactNativeHost =
19 | new ReactNativeHost(this) {
20 | @Override
21 | public boolean getUseDeveloperSupport() {
22 | return BuildConfig.DEBUG;
23 | }
24 |
25 | @Override
26 | protected List getPackages() {
27 | @SuppressWarnings("UnnecessaryLocalVariable")
28 | List packages = new PackageList(this).getPackages();
29 | // Packages that cannot be autolinked yet can be added manually here, for example:
30 | // packages.add(new MyReactNativePackage());
31 | return packages;
32 | }
33 |
34 | @Override
35 | protected String getJSMainModuleName() {
36 | return "index";
37 | }
38 | };
39 |
40 | @Override
41 | public ReactNativeHost getReactNativeHost() {
42 | return mReactNativeHost;
43 | }
44 |
45 | @Override
46 | public void onCreate() {
47 | super.onCreate();
48 | SoLoader.init(this, /* native exopackage */ false);
49 | initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
50 | }
51 |
52 | /**
53 | * Loads Flipper in React Native templates. Call this in the onCreate method with something like
54 | * initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
55 | *
56 | * @param context
57 | * @param reactInstanceManager
58 | */
59 | private static void initializeFlipper(
60 | Context context, ReactInstanceManager reactInstanceManager) {
61 | if (BuildConfig.DEBUG) {
62 | try {
63 | /*
64 | We use reflection here to pick up the class that initializes Flipper,
65 | since Flipper library is not available in release mode
66 | */
67 | Class> aClass = Class.forName("com.qonversion.sample.ReactNativeFlipper");
68 | aClass
69 | .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
70 | .invoke(null, context, reactInstanceManager);
71 | } catch (ClassNotFoundException e) {
72 | e.printStackTrace();
73 | } catch (NoSuchMethodException e) {
74 | e.printStackTrace();
75 | } catch (IllegalAccessException e) {
76 | e.printStackTrace();
77 | } catch (InvocationTargetException e) {
78 | e.printStackTrace();
79 | }
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qonversion/react-native-sdk/a5789cd150e97b4a03a7eeb52b296412468e2d80/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qonversion/react-native-sdk/a5789cd150e97b4a03a7eeb52b296412468e2d80/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qonversion/react-native-sdk/a5789cd150e97b4a03a7eeb52b296412468e2d80/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qonversion/react-native-sdk/a5789cd150e97b4a03a7eeb52b296412468e2d80/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qonversion/react-native-sdk/a5789cd150e97b4a03a7eeb52b296412468e2d80/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qonversion/react-native-sdk/a5789cd150e97b4a03a7eeb52b296412468e2d80/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qonversion/react-native-sdk/a5789cd150e97b4a03a7eeb52b296412468e2d80/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qonversion/react-native-sdk/a5789cd150e97b4a03a7eeb52b296412468e2d80/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qonversion/react-native-sdk/a5789cd150e97b4a03a7eeb52b296412468e2d80/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qonversion/react-native-sdk/a5789cd150e97b4a03a7eeb52b296412468e2d80/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | RN Qonversion
3 |
4 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext {
5 | buildToolsVersion = "28.0.3"
6 | minSdkVersion = 16
7 | compileSdkVersion = 33
8 | targetSdkVersion = 33
9 | }
10 | repositories {
11 | google()
12 | jcenter()
13 | }
14 | dependencies {
15 | classpath('com.android.tools.build:gradle:7.2.0')
16 | classpath('com.google.gms:google-services:4.3.10')
17 |
18 | // NOTE: Do not place your application dependencies here; they belong
19 | // in the individual module build.gradle files
20 | }
21 | }
22 |
23 | allprojects {
24 | repositories {
25 | maven {
26 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
27 | url("$rootDir/../node_modules/react-native/android")
28 | }
29 | maven {
30 | // Android JSC is installed from npm
31 | url("$rootDir/../node_modules/jsc-android/dist")
32 | }
33 |
34 | google()
35 | jcenter()
36 | maven { url 'https://www.jitpack.io' }
37 | mavenLocal()
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/example/android/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 |
20 | # AndroidX package structure to make it clearer which packages are bundled with the
21 | # Android operating system, and which are packaged with your app's APK
22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
23 | android.useAndroidX=true
24 | # Automatically convert third-party libraries to use AndroidX
25 | android.enableJetifier=true
26 |
27 | # Version of flipper SDK to use with React Native
28 | FLIPPER_VERSION=0.125.0
29 | org.gradle.jvmargs=-Xmx4608m
30 |
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qonversion/react-native-sdk/a5789cd150e97b4a03a7eeb52b296412468e2d80/example/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri May 28 00:00:38 MSK 2021
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
7 |
--------------------------------------------------------------------------------
/example/android/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 | # Determine the Java command to use to start the JVM.
86 | if [ -n "$JAVA_HOME" ] ; then
87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
88 | # IBM's JDK on AIX uses strange locations for the executables
89 | JAVACMD="$JAVA_HOME/jre/sh/java"
90 | else
91 | JAVACMD="$JAVA_HOME/bin/java"
92 | fi
93 | if [ ! -x "$JAVACMD" ] ; then
94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
95 |
96 | Please set the JAVA_HOME variable in your environment to match the
97 | location of your Java installation."
98 | fi
99 | else
100 | JAVACMD="java"
101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
102 |
103 | Please set the JAVA_HOME variable in your environment to match the
104 | location of your Java installation."
105 | fi
106 |
107 | # Increase the maximum file descriptors if we can.
108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
109 | MAX_FD_LIMIT=`ulimit -H -n`
110 | if [ $? -eq 0 ] ; then
111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
112 | MAX_FD="$MAX_FD_LIMIT"
113 | fi
114 | ulimit -n $MAX_FD
115 | if [ $? -ne 0 ] ; then
116 | warn "Could not set maximum file descriptor limit: $MAX_FD"
117 | fi
118 | else
119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
120 | fi
121 | fi
122 |
123 | # For Darwin, add options to specify how the application appears in the dock
124 | if $darwin; then
125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
126 | fi
127 |
128 | # For Cygwin or MSYS, switch paths to Windows format before running java
129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
132 | JAVACMD=`cygpath --unix "$JAVACMD"`
133 |
134 | # We build the pattern for arguments to be converted via cygpath
135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
136 | SEP=""
137 | for dir in $ROOTDIRSRAW ; do
138 | ROOTDIRS="$ROOTDIRS$SEP$dir"
139 | SEP="|"
140 | done
141 | OURCYGPATTERN="(^($ROOTDIRS))"
142 | # Add a user-defined pattern to the cygpath arguments
143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
145 | fi
146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
147 | i=0
148 | for arg in "$@" ; do
149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
151 |
152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
154 | else
155 | eval `echo args$i`="\"$arg\""
156 | fi
157 | i=$((i+1))
158 | done
159 | case $i in
160 | (0) set -- ;;
161 | (1) set -- "$args0" ;;
162 | (2) set -- "$args0" "$args1" ;;
163 | (3) set -- "$args0" "$args1" "$args2" ;;
164 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
165 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
166 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
167 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
168 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
169 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
170 | esac
171 | fi
172 |
173 | # Escape application args
174 | save () {
175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
176 | echo " "
177 | }
178 | APP_ARGS=$(save "$@")
179 |
180 | # Collect all arguments for the java command, following the shell quoting and substitution rules
181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
182 |
183 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
184 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
185 | cd "$(dirname "$0")"
186 | fi
187 |
188 | exec "$JAVACMD" "$@"
189 |
--------------------------------------------------------------------------------
/example/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
34 |
35 | @rem Find java.exe
36 | if defined JAVA_HOME goto findJavaFromJavaHome
37 |
38 | set JAVA_EXE=java.exe
39 | %JAVA_EXE% -version >NUL 2>&1
40 | if "%ERRORLEVEL%" == "0" goto init
41 |
42 | echo.
43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
44 | echo.
45 | echo Please set the JAVA_HOME variable in your environment to match the
46 | echo location of your Java installation.
47 |
48 | goto fail
49 |
50 | :findJavaFromJavaHome
51 | set JAVA_HOME=%JAVA_HOME:"=%
52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
53 |
54 | if exist "%JAVA_EXE%" goto init
55 |
56 | echo.
57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
58 | echo.
59 | echo Please set the JAVA_HOME variable in your environment to match the
60 | echo location of your Java installation.
61 |
62 | goto fail
63 |
64 | :init
65 | @rem Get command-line arguments, handling Windows variants
66 |
67 | if not "%OS%" == "Windows_NT" goto win9xME_args
68 |
69 | :win9xME_args
70 | @rem Slurp the command line arguments.
71 | set CMD_LINE_ARGS=
72 | set _SKIP=2
73 |
74 | :win9xME_args_slurp
75 | if "x%~1" == "x" goto execute
76 |
77 | set CMD_LINE_ARGS=%*
78 |
79 | :execute
80 | @rem Setup the command line
81 |
82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
83 |
84 | @rem Execute Gradle
85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
86 |
87 | :end
88 | @rem End local scope for the variables with windows NT shell
89 | if "%ERRORLEVEL%"=="0" goto mainEnd
90 |
91 | :fail
92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
93 | rem the _cmd.exe /c_ return code!
94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
95 | exit /b 1
96 |
97 | :mainEnd
98 | if "%OS%"=="Windows_NT" endlocal
99 |
100 | :omega
101 |
--------------------------------------------------------------------------------
/example/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'example'
2 | include ':react-native-qonversion'
3 | project(':react-native-qonversion').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-qonversion/android')
4 | include ':react-native-qonversion'
5 | project(':react-native-qonversion').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-qonversion/android')
6 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
7 | include ':app'
8 |
--------------------------------------------------------------------------------
/example/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example",
3 | "displayName": "example"
4 | }
--------------------------------------------------------------------------------
/example/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: ['module:metro-react-native-babel-preset'],
3 | };
4 |
--------------------------------------------------------------------------------
/example/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @format
3 | */
4 |
5 | import {AppRegistry} from 'react-native';
6 | import App from './App';
7 | import {name as appName} from './app.json';
8 |
9 | AppRegistry.registerComponent(appName, () => App);
10 |
--------------------------------------------------------------------------------
/example/ios/Podfile:
--------------------------------------------------------------------------------
1 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
2 | require_relative '../node_modules/react-native/scripts/react_native_pods'
3 |
4 | use_modular_headers!
5 | platform :ios, '13.0'
6 |
7 | target 'example' do
8 | config = use_native_modules!
9 |
10 | # Flags change depending on the env values.
11 | flags = get_default_flags()
12 |
13 | use_react_native!(
14 | :path => config[:reactNativePath],
15 | # Hermes is now enabled by default. Disable by setting this flag to false.
16 | # Upcoming versions of React Native may rely on get_default_flags(), but
17 | # we make it explicit here to aid in the React Native upgrade process.
18 | :hermes_enabled => false,
19 | :fabric_enabled => flags[:fabric_enabled],
20 | # Enables Flipper.
21 | #
22 | # Note that if you have use_frameworks! enabled, Flipper will not work and
23 | # you should disable the next line.
24 | :flipper_configuration => FlipperConfiguration.enabled,
25 | # An absolute path to your application root.
26 | :app_path => "#{Pod::Config.instance.installation_root}/.."
27 | )
28 |
29 | target 'exampleTests' do
30 | inherit! :complete
31 | # Pods for testing
32 | end
33 |
34 | pod 'RCT-Folly', :podspec => '../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec', :modular_headers => false
35 | pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec', :modular_headers => false
36 | pod 'fmt', :modular_headers => false
37 |
38 | post_install do |installer|
39 | react_native_post_install(
40 | installer,
41 | # Set `mac_catalyst_enabled` to `true` in order to apply patches
42 | # necessary for Mac Catalyst builds
43 | :mac_catalyst_enabled => false
44 | )
45 | __apply_Xcode_12_5_M1_post_install_workaround(installer)
46 |
47 | installer.pods_project.targets.each do |target|
48 | if target.name == 'Flipper'
49 | file_path = 'Pods/Flipper/xplat/Flipper/FlipperTransportTypes.h'
50 | contents = File.read(file_path)
51 | unless contents.include?('#include ')
52 | File.open(file_path, 'w') do |file|
53 | file.puts('#include ')
54 | file.puts(contents)
55 | end
56 | end
57 | end
58 | end
59 | end
60 | end
61 |
62 | target 'example-tvOS' do
63 | # Pods for example-tvOS
64 |
65 | target 'example-tvOSTests' do
66 | inherit! :search_paths
67 | # Pods for testing
68 | end
69 | end
70 |
--------------------------------------------------------------------------------
/example/ios/example-tvOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | NSAppTransportSecurity
26 |
27 | NSExceptionDomains
28 |
29 | localhost
30 |
31 | NSExceptionAllowsInsecureHTTPLoads
32 |
33 |
34 |
35 |
36 | NSLocationWhenInUseUsageDescription
37 |
38 | UILaunchStoryboardName
39 | LaunchScreen
40 | UIRequiredDeviceCapabilities
41 |
42 | armv7
43 |
44 | UISupportedInterfaceOrientations
45 |
46 | UIInterfaceOrientationPortrait
47 | UIInterfaceOrientationLandscapeLeft
48 | UIInterfaceOrientationLandscapeRight
49 |
50 | UIViewControllerBasedStatusBarAppearance
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/example/ios/example-tvOSTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/example/ios/example.xcodeproj/xcshareddata/xcschemes/example-tvOS.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
53 |
55 |
61 |
62 |
63 |
64 |
70 |
72 |
78 |
79 |
80 |
81 |
83 |
84 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/example/ios/example.xcodeproj/xcshareddata/xcschemes/example.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
33 |
39 |
40 |
41 |
42 |
43 |
53 |
55 |
61 |
62 |
63 |
64 |
70 |
72 |
78 |
79 |
80 |
81 |
83 |
84 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/example/ios/example.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/example/ios/example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/example.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/example/AppDelegate.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | #import
4 |
5 | @interface AppDelegate : UIResponder
6 |
7 | @property (nonatomic, strong) UIWindow *window;
8 |
9 | @end
10 |
--------------------------------------------------------------------------------
/example/ios/example/AppDelegate.m:
--------------------------------------------------------------------------------
1 | #import "AppDelegate.h"
2 |
3 | #import
4 | #import
5 | #import
6 |
7 | #if DEBUG
8 | #import
9 | #import
10 | #import
11 | #import
12 | #import
13 | #import
14 | #import
15 | #import
16 |
17 | static void InitializeFlipper(UIApplication *application) {
18 | FlipperClient *client = [FlipperClient sharedClient];
19 | SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults];
20 | [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]];
21 | [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]];
22 | [client addPlugin:[FlipperKitReactPlugin new]];
23 | [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]];
24 | [client start];
25 | }
26 | #endif
27 |
28 | @implementation AppDelegate
29 |
30 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
31 | {
32 | #if DEBUG
33 | InitializeFlipper(application);
34 | #endif
35 |
36 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
37 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
38 | moduleName:@"example"
39 | initialProperties:nil];
40 |
41 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
42 |
43 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
44 | UIViewController *rootViewController = [UIViewController new];
45 | rootViewController.view = rootView;
46 | self.window.rootViewController = rootViewController;
47 | [self.window makeKeyAndVisible];
48 |
49 | // Define UNUserNotificationCenter
50 | UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
51 | center.delegate = self;
52 |
53 | return YES;
54 | }
55 |
56 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
57 | {
58 | #if DEBUG
59 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
60 | #else
61 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
62 | #endif
63 | }
64 |
65 | // Required for the register event.
66 | - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
67 | {
68 | [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
69 | }
70 | // Required for the notification event. You must call the completion handler after handling the remote notification.
71 | - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
72 | fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
73 | {
74 | [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
75 | }
76 | // Required for the registrationError event.
77 | - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
78 | {
79 | [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
80 | }
81 | // Required for localNotification event
82 | - (void)userNotificationCenter:(UNUserNotificationCenter *)center
83 | didReceiveNotificationResponse:(UNNotificationResponse *)response
84 | withCompletionHandler:(void (^)(void))completionHandler
85 | {
86 | [RNCPushNotificationIOS didReceiveNotificationResponse:response];
87 | }
88 | //Called when a notification is delivered to a foreground app.
89 | -(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
90 | {
91 | completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert | UNNotificationPresentationOptionBadge);
92 | }
93 |
94 | @end
95 |
--------------------------------------------------------------------------------
/example/ios/example/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/example/ios/example/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "29x29",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "29x29",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "40x40",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "40x40",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "60x60",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "60x60",
31 | "scale" : "3x"
32 | }
33 | ],
34 | "info" : {
35 | "version" : 1,
36 | "author" : "xcode"
37 | }
38 | }
--------------------------------------------------------------------------------
/example/ios/example/Images.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/example/ios/example/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | RN Qonversion
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | LSRequiresIPhoneOS
26 |
27 | NSAppTransportSecurity
28 |
29 | NSAllowsArbitraryLoads
30 |
31 | NSExceptionDomains
32 |
33 | localhost
34 |
35 | NSExceptionAllowsInsecureHTTPLoads
36 |
37 |
38 |
39 |
40 | NSLocationWhenInUseUsageDescription
41 |
42 | UIBackgroundModes
43 |
44 | remote-notification
45 |
46 | UILaunchStoryboardName
47 | LaunchScreen
48 | UIRequiredDeviceCapabilities
49 |
50 | armv7
51 |
52 | UISupportedInterfaceOrientations
53 |
54 | UIInterfaceOrientationPortrait
55 | UIInterfaceOrientationLandscapeLeft
56 | UIInterfaceOrientationLandscapeRight
57 |
58 | UIViewControllerBasedStatusBarAppearance
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/example/ios/example/example.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | aps-environment
6 | development
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/example/main.m:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | #import "AppDelegate.h"
4 |
5 | int main(int argc, char * argv[]) {
6 | @autoreleasepool {
7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/example/ios/exampleTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/example/ios/exampleTests/exampleTests.m:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | #import
5 | #import
6 |
7 | #define TIMEOUT_SECONDS 600
8 | #define TEXT_TO_LOOK_FOR @"Welcome to React"
9 |
10 | @interface exampleTests : XCTestCase
11 |
12 | @end
13 |
14 | @implementation exampleTests
15 |
16 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test
17 | {
18 | if (test(view)) {
19 | return YES;
20 | }
21 | for (UIView *subview in [view subviews]) {
22 | if ([self findSubviewInView:subview matching:test]) {
23 | return YES;
24 | }
25 | }
26 | return NO;
27 | }
28 |
29 | - (void)testRendersWelcomeScreen
30 | {
31 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController];
32 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
33 | BOOL foundElement = NO;
34 |
35 | __block NSString *redboxError = nil;
36 | #ifdef DEBUG
37 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
38 | if (level >= RCTLogLevelError) {
39 | redboxError = message;
40 | }
41 | });
42 | #endif
43 |
44 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) {
45 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
46 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
47 |
48 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) {
49 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) {
50 | return YES;
51 | }
52 | return NO;
53 | }];
54 | }
55 |
56 | #ifdef DEBUG
57 | RCTSetLogFunction(RCTDefaultLogFunction);
58 | #endif
59 |
60 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
61 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
62 | }
63 |
64 |
65 | @end
66 |
--------------------------------------------------------------------------------
/example/ios/qonversion_ios_fallbacks.json:
--------------------------------------------------------------------------------
1 | {
2 | "products": [
3 | {
4 | "id": "weekly",
5 | "duration": 0,
6 | "store_id": "io.qonversion.weekly",
7 | "type": 1
8 | },
9 | {
10 | "id": "consumable",
11 | "duration": null,
12 | "store_id": "io.qonversion.consumable",
13 | "type": 2
14 | },
15 | {
16 | "id": "subs_plus_trial",
17 | "duration": 1,
18 | "store_id": "io.qonversion.subs.monthly.plus.trial",
19 | "type": 0
20 | },
21 | {
22 | "id": "annual",
23 | "duration": 4,
24 | "store_id": "io.qonversion.subs.annual",
25 | "type": 0
26 | },
27 | {
28 | "id": "in_app",
29 | "duration": null,
30 | "store_id": "io.qonversion.nonconsumable",
31 | "type": 2
32 | }
33 | ],
34 | "offerings": [
35 | {
36 | "id": "main",
37 | "tag": 1,
38 | "products": [
39 | {
40 | "id": "weekly",
41 | "duration": 0,
42 | "store_id": "io.qonversion.weekly",
43 | "type": 1
44 | },
45 | {
46 | "id": "annual",
47 | "duration": 4,
48 | "store_id": "io.qonversion.subs.annual",
49 | "type": 0
50 | },
51 | {
52 | "id": "consumable",
53 | "duration": null,
54 | "store_id": "io.qonversion.consumable",
55 | "type": 2
56 | }
57 | ]
58 | },
59 | {
60 | "id": "discounted_offer",
61 | "tag": 0,
62 | "products": []
63 | }
64 | ],
65 | "products_permissions": {
66 | "weekly": [
67 | "plus"
68 | ],
69 | "consumable": [],
70 | "subs_plus_trial": [
71 | "standart"
72 | ],
73 | "annual": [
74 | "standart",
75 | "sample"
76 | ],
77 | "in_app": [
78 | "Premium Movies"
79 | ]
80 | },
81 | "remote_config_list": [
82 | {
83 | "experiment": null,
84 | "payload": {
85 | "CTA": "Start Trial",
86 | "CTA_color": "#307BF6",
87 | "main_image": "[IMAGE_URL]",
88 | "product_id": "prod_7d_trial_5.99",
89 | "show_close_button": true
90 | },
91 | "source": {
92 | "assignment_type": "auto",
93 | "context_key": "main_paywall",
94 | "name": "default paywall",
95 | "type": "remote_configuration",
96 | "uid": "0dcb1bd9-9bc3-4668-84aa-4540d1042c5d"
97 | }
98 | },
99 | {
100 | "experiment": null,
101 | "payload": {
102 | "CTA": "Start you trial",
103 | "CTA_color": "red",
104 | "main_image": "111",
105 | "product_id": "123123123123123",
106 | "show_close_button": true
107 | },
108 | "source": {
109 | "assignment_type": "auto",
110 | "context_key": "",
111 | "name": "Default settings",
112 | "type": "remote_configuration",
113 | "uid": "12feb1dd-8096-47bc-a5a1-443fd2828ecc"
114 | }
115 | },
116 | {
117 | "experiment": null,
118 | "payload": {
119 | "test_key": "test_value"
120 | },
121 | "source": {
122 | "assignment_type": "auto",
123 | "context_key": "test_context_key",
124 | "name": "Test with context key1",
125 | "type": "remote_configuration",
126 | "uid": "c5077ec4-acf4-41ea-8b43-05114be5d7ce"
127 | }
128 | },
129 | {
130 | "experiment": null,
131 | "payload": {
132 | "test_key_2": "test_value_2"
133 | },
134 | "source": {
135 | "assignment_type": "auto",
136 | "context_key": "test_context_key_2",
137 | "name": "Test with context key2 - copy",
138 | "type": "remote_configuration",
139 | "uid": "1c000f2a-2f4b-4736-b5dd-75b13bf73deb"
140 | }
141 | },
142 | {
143 | "experiment": null,
144 | "payload": {
145 | "bool": true,
146 | "json": {
147 | "key": "value"
148 | }
149 | },
150 | "source": {
151 | "assignment_type": "auto",
152 | "context_key": "swift_key ",
153 | "name": "Swift",
154 | "type": "remote_configuration",
155 | "uid": "9f85d738-56d8-4f6c-b54a-c08658be2cb4"
156 | }
157 | }
158 | ]
159 | }
160 |
--------------------------------------------------------------------------------
/example/metro.config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Metro configuration for React Native
3 | * https://github.com/facebook/react-native
4 | *
5 | * @format
6 | */
7 |
8 | module.exports = {
9 | transformer: {
10 | getTransformOptions: async () => ({
11 | transform: {
12 | experimentalImportSupport: false,
13 | inlineRequires: false,
14 | },
15 | }),
16 | },
17 | };
18 |
--------------------------------------------------------------------------------
/example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "reAndroid": "yarn clean && yarn android",
7 | "android": "react-native run-android",
8 | "reIos": "yarn cleanIos && yarn ios",
9 | "ios": "react-native run-ios",
10 | "start": "react-native start",
11 | "test": "jest",
12 | "lint": "eslint .",
13 | "clean": "rm -rf node_modules/ && cd .. && rm -rf node_modules/ && yarn install && yarn prepare && cd example && yarn install",
14 | "cleanIos": "yarn clean && cd ios && pod install && cd .."
15 | },
16 | "dependencies": {
17 | "@react-native-community/push-notification-ios": "^1.10.1",
18 | "babel-preset-react-native": "2.1.0",
19 | "react": "18.1.0",
20 | "react-native": "0.70.7",
21 | "react-native-qonversion": "file:../"
22 | },
23 | "devDependencies": {
24 | "@babel/core": "^7.12.9",
25 | "@babel/runtime": "^7.12.5",
26 | "@react-native-community/eslint-config": "^2.0.0",
27 | "babel-jest": "^26.6.3",
28 | "eslint": "^7.32.0",
29 | "jest": "^26.6.3",
30 | "metro-react-native-babel-preset": "^0.72.3",
31 | "react-test-renderer": "18.1.0"
32 | },
33 | "jest": {
34 | "preset": "react-native"
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/example/q_icon@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qonversion/react-native-sdk/a5789cd150e97b4a03a7eeb52b296412468e2d80/example/q_icon@3x.png
--------------------------------------------------------------------------------
/fastlane/Appfile:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qonversion/react-native-sdk/a5789cd150e97b4a03a7eeb52b296412468e2d80/fastlane/Appfile
--------------------------------------------------------------------------------
/fastlane/Fastfile:
--------------------------------------------------------------------------------
1 | def update_js(new_version)
2 | path = Dir['../src/**/QonversionInternal.ts'].first
3 | regex = /const sdkVersion = ".*";/
4 | result_value = "const sdkVersion = \"#{new_version}\";"
5 |
6 | update_file(path, regex, result_value)
7 | end
8 |
9 | def update_package(new_version)
10 | path = "../package.json"
11 | regex = /"version": ".*",/
12 | result_value = "\"version\": \"#{new_version}\","
13 |
14 | update_file(path, regex, result_value)
15 | end
16 |
17 | def upgrade_sandwich_android(new_version)
18 | path = "../android/build.gradle"
19 | common_part = "implementation \"io.qonversion.sandwich:sandwich:"
20 | regex = /#{common_part}.*"/
21 | result_value = "#{common_part}#{new_version}\""
22 |
23 | update_file(path, regex, result_value)
24 | end
25 |
26 | def upgrade_sandwich_ios(new_version)
27 | path = "../react-native-qonversion.podspec"
28 | common_part = "s.dependency \"QonversionSandwich\", \""
29 | regex = /#{common_part}.*"/
30 | result_value = "#{common_part}#{new_version}\""
31 |
32 | update_file(path, regex, result_value)
33 | end
34 |
35 | def update_file(path, regex, result_value)
36 | file = File.read(path)
37 | new_content = file.gsub(regex, result_value)
38 | File.open(path, 'w') { |line| line.puts new_content }
39 | end
40 |
41 | def get_tag
42 | tag = last_git_tag()
43 | puts tag
44 | result_tag = tag.scan(%r{\d{1,2}.\d{1,2}.\d{1,3}}).first
45 | return result_tag
46 | end
47 |
48 | def calculate_minor_version(tag)
49 | major, minor, patch = parse_versions(tag)
50 | new_minor_version = minor.to_i.next.to_s
51 | new_version = major + "." + new_minor_version + "." + "0"
52 | return new_version
53 | end
54 |
55 | def calculate_patch_version(tag)
56 | major, minor, patch = parse_versions(tag)
57 | new_patch_version = patch.to_i.next.to_s
58 | new_version = major + "." + minor + "." + new_patch_version
59 |
60 | return new_version
61 | end
62 |
63 | def push_tag(tag)
64 | system("git checkout develop")
65 | system("git pull origin develop")
66 | add_git_tag(tag: tag)
67 | push_git_tags(tag: tag)
68 | end
69 |
70 | def parse_versions(tag)
71 | split_version_array = tag.split(".", 3)
72 |
73 | if split_version_array.length == 3
74 | major = split_version_array[0]
75 | minor = split_version_array[1]
76 | patch = split_version_array[2]
77 |
78 | return major, minor, patch
79 | end
80 | end
81 |
82 | lane :patch do
83 | tag = get_tag
84 | new_version = calculate_patch_version(tag)
85 | new_tag = "prerelease/" + new_version
86 | push_tag(new_tag)
87 | end
88 |
89 | lane :minor do
90 | tag = get_tag
91 | new_version = calculate_minor_version(tag)
92 | new_tag = "prerelease/" + new_version
93 | push_tag(new_tag)
94 | end
95 |
96 | lane :bump do |options|
97 | new_version = options[:version]
98 |
99 | update_js(new_version)
100 | update_package(new_version)
101 | end
102 |
103 | lane :upgrade_sandwich do |options|
104 | new_version = options[:version]
105 |
106 | upgrade_sandwich_android(new_version)
107 | upgrade_sandwich_ios(new_version)
108 | end
109 |
110 | lane :provide_next_patch_version do
111 | tag = get_tag
112 | new_version = calculate_patch_version(tag)
113 | sh("echo version=#{new_version} >> \"$GITHUB_ENV\"")
114 | end
115 |
--------------------------------------------------------------------------------
/fastlane/README.md:
--------------------------------------------------------------------------------
1 | fastlane documentation
2 | ----
3 |
4 | # Installation
5 |
6 | Make sure you have the latest version of the Xcode command line tools installed:
7 |
8 | ```sh
9 | xcode-select --install
10 | ```
11 |
12 | For _fastlane_ installation instructions, see [Installing _fastlane_](https://docs.fastlane.tools/#installing-fastlane)
13 |
14 | # Available Actions
15 |
16 | ### patch
17 |
18 | ```sh
19 | [bundle exec] fastlane patch
20 | ```
21 |
22 |
23 |
24 | ### minor
25 |
26 | ```sh
27 | [bundle exec] fastlane minor
28 | ```
29 |
30 |
31 |
32 | ### bump
33 |
34 | ```sh
35 | [bundle exec] fastlane bump
36 | ```
37 |
38 |
39 |
40 | ### upgrade_sandwich
41 |
42 | ```sh
43 | [bundle exec] fastlane upgrade_sandwich
44 | ```
45 |
46 |
47 |
48 | ### provide_next_patch_version
49 |
50 | ```sh
51 | [bundle exec] fastlane provide_next_patch_version
52 | ```
53 |
54 |
55 |
56 | ----
57 |
58 | This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run.
59 |
60 | More information about _fastlane_ can be found on [fastlane.tools](https://fastlane.tools).
61 |
62 | The documentation of _fastlane_ can be found on [docs.fastlane.tools](https://docs.fastlane.tools).
63 |
--------------------------------------------------------------------------------
/fastlane/report.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/Qonversion.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ios/Qonversion.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ios/RNAutomations.h:
--------------------------------------------------------------------------------
1 | //
2 | // RNAutomations.h
3 | // Qonversion
4 | //
5 | // Created by Kamo Spertsyan on 11.03.2022.
6 | // Copyright © 2022 Facebook. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import
12 |
13 | NS_ASSUME_NONNULL_BEGIN
14 |
15 | @interface RNAutomations : RCTEventEmitter
16 |
17 | @end
18 |
19 | NS_ASSUME_NONNULL_END
20 |
--------------------------------------------------------------------------------
/ios/RNAutomations.m:
--------------------------------------------------------------------------------
1 | //
2 | // RNAutomations.m
3 | // Qonversion
4 | //
5 | // Created by Kamo Spertsyan on 11.03.2022.
6 | // Copyright © 2022 Facebook. All rights reserved.
7 | //
8 |
9 | #import "RNAutomations.h"
10 | @import QonversionSandwich;
11 |
12 | @interface RNAutomations ()
13 |
14 | @property (nonatomic, strong) AutomationsSandwich *sandwich;
15 |
16 | @end
17 |
18 | @implementation RNAutomations
19 |
20 | - (instancetype)init {
21 | self = [super init];
22 |
23 | if (self) {
24 | _sandwich = [AutomationsSandwich new];
25 | }
26 |
27 | return self;
28 | }
29 |
30 | + (BOOL)requiresMainQueueSetup
31 | {
32 | return NO;
33 | }
34 |
35 | RCT_EXPORT_MODULE();
36 |
37 | RCT_EXPORT_METHOD(subscribe) {
38 | [_sandwich subscribe:self];
39 | }
40 |
41 | RCT_EXPORT_METHOD(setNotificationsToken:(NSString *)token) {
42 | [_sandwich setNotificationToken:token];
43 | }
44 |
45 | RCT_EXPORT_METHOD(getNotificationCustomPayload:(NSDictionary *)notificationData
46 | completion:(RCTPromiseResolveBlock)completion
47 | rejecter:(RCTPromiseRejectBlock)reject) {
48 | if (![notificationData isKindOfClass:[NSDictionary class]]) {
49 | completion(nil);
50 | return;
51 | }
52 |
53 | NSDictionary *payload = [_sandwich getNotificationCustomPayload:notificationData];
54 | completion(payload == nil ? nil : @[payload]);
55 | }
56 |
57 | RCT_EXPORT_METHOD(handleNotification:(NSDictionary *)notificationData
58 | completion:(RCTPromiseResolveBlock)completion
59 | rejecter:(RCTPromiseRejectBlock)reject) {
60 | if (![notificationData isKindOfClass:[NSDictionary class]]) {
61 | completion(@[@(NO)]);
62 | return;
63 | }
64 |
65 | BOOL isQonversionNotification = [_sandwich handleNotification:notificationData];
66 | completion(@[@(isQonversionNotification)]);
67 | }
68 |
69 | RCT_EXPORT_METHOD(showScreen:(NSString *)screenId
70 | completion:(RCTPromiseResolveBlock)completion
71 | rejecter:(RCTPromiseRejectBlock)reject) {
72 | [_sandwich showScreen:screenId completion:^(NSDictionary * _Nullable result, SandwichError * _Nullable error) {
73 | if (error) {
74 | reject(error.code, error.details, nil);
75 |
76 | return;
77 | }
78 |
79 | completion(@[result]);
80 | }];
81 | }
82 |
83 | RCT_EXPORT_METHOD(setScreenPresentationConfig:(NSDictionary *)config
84 | screenId:(NSString *)screenId) {
85 | [_sandwich setScreenPresentationConfig:config forScreenId:screenId];
86 | }
87 |
88 | - (void)automationDidTriggerWithEvent:(NSString * _Nonnull)event payload:(NSDictionary * _Nullable)payload {
89 | [self sendEventWithName:event body:payload];
90 | }
91 |
92 | #pragma mark - Emitter
93 |
94 | - (NSArray *)supportedEvents {
95 | return [self.sandwich getAvailableEvents];
96 | }
97 |
98 | @end
99 |
--------------------------------------------------------------------------------
/ios/RNQonversion.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | @import QonversionSandwich;
4 |
5 | @interface RNQonversion : RCTEventEmitter
6 |
7 | - (void)handleResult:(NSDictionary *)result
8 | error:(SandwichError *)error
9 | completion:(RCTPromiseResolveBlock)completion
10 | rejecter:(RCTPromiseRejectBlock)reject;
11 |
12 | @end
13 |
--------------------------------------------------------------------------------
/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-qonversion",
3 | "version": "2.2.0",
4 | "lockfileVersion": 1
5 | }
6 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-qonversion",
3 | "title": "React Native Qonversion",
4 | "version": "8.2.3",
5 | "description": "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 content using our StoreKit wrapper and Google Play Billing wrapper.",
6 | "main": "build/index.js",
7 | "types": "build/index.d.ts",
8 | "files": [
9 | "build",
10 | "android",
11 | "!android/local.properties",
12 | "!android/gradle",
13 | "!android/.gradle",
14 | "!android/gradlew*",
15 | "!android/build",
16 | "ios",
17 | "!ios/build",
18 | "!ios/Qonversion.xcodeproj/xcuserdata",
19 | "!ios/Qonversion.xcworkspace",
20 | "react-native-qonversion.podspec",
21 | "!.github",
22 | "!**/.gitignore",
23 | "!**/.gitattributes",
24 | "!**/.idea"
25 | ],
26 | "scripts": {
27 | "prepare": "rm -rf build && tsc",
28 | "test": "echo \"Error: no test specified\" && exit 1"
29 | },
30 | "repository": {
31 | "type": "git",
32 | "url": "git+https://github.com/qonversion/react-native-sdk.git",
33 | "baseUrl": "https://github.com/qonversion/react-native-sdk"
34 | },
35 | "keywords": [
36 | "react-native",
37 | "qonversion",
38 | "StoreKit",
39 | "SKStoreKit",
40 | "Google",
41 | "Play",
42 | "Billing",
43 | "in-app",
44 | "Purchases"
45 | ],
46 | "author": {
47 | "name": "Qonversion",
48 | "email": "hi@qonversion.io"
49 | },
50 | "license": "MIT",
51 | "licenseFilename": "LICENSE",
52 | "readmeFilename": "README.md",
53 | "devDependencies": {
54 | "typescript": "^4.2.4",
55 | "@types/react": "*",
56 | "@types/react-native": "*"
57 | },
58 | "peerDependencies": {
59 | "react": "^16.8.1 || ^17.0.0 || ^18.0.0",
60 | "react-native": ">=0.60.0-rc.0 <1.0.x"
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/react-native-qonversion.podspec:
--------------------------------------------------------------------------------
1 | require "json"
2 |
3 | package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4 |
5 | Pod::Spec.new do |s|
6 | s.name = "react-native-qonversion"
7 | s.version = package["version"]
8 | s.summary = package["description"]
9 | s.description = <<-DESC
10 | react-native-qonversion
11 | DESC
12 | s.homepage = "https://github.com/github_account/react-native-qonversion"
13 | # brief license entry:
14 | s.license = "MIT"
15 | # optional - use expanded license entry instead:
16 | # s.license = { :type => "MIT", :file => "LICENSE" }
17 | s.authors = { "Your Name" => "yourname@email.com" }
18 | s.platforms = { :ios => "9.0" }
19 | s.source = { :git => "https://github.com/github_account/react-native-qonversion.git", :tag => "#{s.version}" }
20 |
21 | s.source_files = "ios/**/*.{h,m,swift}"
22 | s.requires_arc = true
23 |
24 | s.dependency "React"
25 | s.dependency "QonversionSandwich", "5.2.0"
26 | end
27 |
--------------------------------------------------------------------------------
/src/Automations.ts:
--------------------------------------------------------------------------------
1 | import AutomationsApi from './AutomationsApi';
2 | import Qonversion from './Qonversion';
3 | import AutomationsInternal from './internal/AutomationsInternal';
4 |
5 | export default class Automations {
6 | private constructor() {}
7 |
8 | private static backingInstance: AutomationsApi | undefined;
9 |
10 | /**
11 | * Use this variable to get a current initialized instance of the Qonversion Automations.
12 | * Please, use Automations only after calling {@link Qonversion.initialize}.
13 | * Otherwise, trying to access the variable will cause an error.
14 | *
15 | * @return Current initialized instance of the Qonversion Automations.
16 | * @throws error if Qonversion has not been initialized.
17 | */
18 | static getSharedInstance(): AutomationsApi {
19 | if (!this.backingInstance) {
20 | try {
21 | Qonversion.getSharedInstance();
22 | } catch (e) {
23 | throw "Qonversion has not been initialized. " +
24 | "Automations should be used after Qonversion is initialized."
25 | }
26 |
27 | this.backingInstance = new AutomationsInternal();
28 | }
29 |
30 | return this.backingInstance;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/AutomationsApi.ts:
--------------------------------------------------------------------------------
1 | import {AutomationsDelegate} from './dto/AutomationsDelegate';
2 | import {ScreenPresentationConfig} from './dto/ScreenPresentationConfig';
3 |
4 | interface AutomationsApi {
5 | /**
6 | * The Automations delegate is responsible for handling in-app screens and actions when push notification is received.
7 | * Make sure the method is called before {@link AutomationsApi.handleNotification}.
8 | *
9 | * @param delegate the delegate to be notified about Automations events.
10 | */
11 | setDelegate(delegate: AutomationsDelegate): void;
12 |
13 | /**
14 | * Set push token to Qonversion to enable Qonversion push notifications
15 | *
16 | * @deprecated Consider removing this method calls. Qonversion is not working with push notifications anymore.
17 | * @param token Firebase device token for Android. APNs device token for iOS.
18 | */
19 | setNotificationsToken(token: string): void;
20 |
21 | /**
22 | * Call to handle push notifications sent by Qonversion Automations.
23 | *
24 | * @deprecated Consider removing this method calls. Qonversion is not working with push notifications anymore.
25 | * @param notificationData notification payload data
26 | * @returns true when a push notification was received from Qonversion. Otherwise, returns false, so you need to handle the notification yourself
27 | *
28 | * @see [Firebase RemoteMessage data](https://pub.dev/documentation/firebase_messaging_platform_interface/latest/firebase_messaging_platform_interface/RemoteMessage/data.html)
29 | * @see [APNs notification data](https://developer.apple.com/documentation/usernotifications/unnotificationcontent/1649869-userinfo)
30 | */
31 | handleNotification(notificationData: Map): Promise;
32 |
33 | /**
34 | * Get parsed custom payload, which you added to the notification in the dashboard
35 | *
36 | @deprecated Consider removing this method calls. Qonversion is not working with push notifications anymore.
37 | * @param notificationData notification payload data
38 | * @returns a map with custom payload from the notification or null if it's not provided.
39 | */
40 | getNotificationCustomPayload(notificationData: Map): Promise | null>;
41 |
42 | /**
43 | * Show the screen using its ID.
44 | * @param screenId identifier of the screen which must be shown
45 | * @returns promise to await for completion.
46 | */
47 | showScreen(screenId: string): Promise;
48 |
49 | /**
50 | * Set the configuration of screen representation.
51 | * @param config a configuration to apply.
52 | * @param screenId identifier of screen, to which a config should be applied.
53 | * If not provided, the config is used for all the screens.
54 | */
55 | setScreenPresentationConfig(config: ScreenPresentationConfig, screenId?: string): void;
56 | }
57 |
58 | export default AutomationsApi;
59 |
--------------------------------------------------------------------------------
/src/Qonversion.ts:
--------------------------------------------------------------------------------
1 | import QonversionConfig from './QonversionConfig';
2 | import QonversionApi from './QonversionApi';
3 | import QonversionInternal from './internal/QonversionInternal';
4 |
5 | export default class Qonversion {
6 | private constructor() {}
7 |
8 | private static backingInstance: QonversionApi | undefined;
9 |
10 | /**
11 | * Use this variable to get a current initialized instance of the Qonversion SDK.
12 | * Please, use the property only after calling {@link Qonversion.initialize}.
13 | * Otherwise, trying to access the variable will cause an exception.
14 | *
15 | * @return Current initialized instance of the Qonversion SDK.
16 | * @throws error if the instance has not been initialized
17 | */
18 | static getSharedInstance(): QonversionApi {
19 | if (!this.backingInstance) {
20 | throw "Qonversion has not been initialized. You should call " +
21 | "the initialize method before accessing the shared instance of Qonversion."
22 | }
23 |
24 | return this.backingInstance;
25 | }
26 |
27 | /**
28 | * An entry point to use Qonversion SDK. Call to initialize Qonversion SDK with required and extra configs.
29 | * The function is the best way to set additional configs you need to use Qonversion SDK.
30 | * You still have an option to set a part of additional configs later via calling separate setters.
31 | *
32 | * @param config a config that contains key SDK settings.
33 | * Call {@link QonversionConfigBuilder.build} to configure and create a QonversionConfig instance.
34 | * @return Initialized instance of the Qonversion SDK.
35 | */
36 | static initialize(config: QonversionConfig): QonversionApi {
37 | this.backingInstance = new QonversionInternal(config);
38 | return this.backingInstance;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/QonversionConfig.ts:
--------------------------------------------------------------------------------
1 | import {EntitlementsCacheLifetime, Environment, LaunchMode} from './dto/enums';
2 | import {EntitlementsUpdateListener} from './dto/EntitlementsUpdateListener';
3 |
4 | class QonversionConfig {
5 | readonly projectKey: string;
6 | readonly launchMode: LaunchMode;
7 | readonly environment: Environment;
8 | readonly entitlementsCacheLifetime: EntitlementsCacheLifetime;
9 | readonly entitlementsUpdateListener: EntitlementsUpdateListener | undefined;
10 | readonly proxyUrl: string | undefined;
11 | readonly kidsMode: boolean;
12 |
13 | constructor(
14 | projectKey: string,
15 | launchMode: LaunchMode,
16 | environment: Environment = Environment.PRODUCTION,
17 | entitlementsCacheLifetime: EntitlementsCacheLifetime = EntitlementsCacheLifetime.MONTH,
18 | entitlementsUpdateListener: EntitlementsUpdateListener | undefined = undefined,
19 | proxyUrl: string | undefined,
20 | kidsMode: boolean = false
21 | ) {
22 | this.projectKey = projectKey;
23 | this.launchMode = launchMode;
24 | this.environment = environment;
25 | this.entitlementsCacheLifetime = entitlementsCacheLifetime;
26 | this.entitlementsUpdateListener = entitlementsUpdateListener;
27 | this.proxyUrl = proxyUrl;
28 | this.kidsMode = kidsMode;
29 | }
30 | }
31 |
32 | export default QonversionConfig;
33 |
--------------------------------------------------------------------------------
/src/QonversionConfigBuilder.ts:
--------------------------------------------------------------------------------
1 | import {EntitlementsCacheLifetime, Environment, LaunchMode} from './dto/enums';
2 | import {EntitlementsUpdateListener} from './dto/EntitlementsUpdateListener';
3 | import QonversionConfig from './QonversionConfig';
4 |
5 | class QonversionConfigBuilder {
6 | private readonly projectKey: string;
7 | private readonly launchMode: LaunchMode;
8 |
9 | constructor(projectKey: string, launchMode: LaunchMode) {
10 | this.projectKey = projectKey;
11 | this.launchMode = launchMode;
12 | }
13 |
14 | private environment: Environment = Environment.PRODUCTION;
15 | private entitlementsCacheLifetime: EntitlementsCacheLifetime = EntitlementsCacheLifetime.MONTH;
16 | private entitlementsUpdateListener: EntitlementsUpdateListener | undefined = undefined;
17 | private proxyUrl: string | undefined = undefined;
18 | private kidsMode: boolean = false;
19 |
20 | /**
21 | * Set current application {@link Environment}. Used to distinguish sandbox and production users.
22 | *
23 | * @param environment current environment.
24 | * @return builder instance for chain calls.
25 | */
26 | setEnvironment(environment: Environment): QonversionConfigBuilder {
27 | this.environment = environment;
28 | return this;
29 | }
30 |
31 | /**
32 | * Entitlements cache is used when there are problems with the Qonversion API
33 | * or internet connection. If so, Qonversion will return the last successfully loaded
34 | * entitlements. The current method allows you to configure how long that cache may be used.
35 | * The default value is {@link EntitlementsCacheLifetime.MONTH}.
36 | *
37 | * @param lifetime desired entitlements cache lifetime duration
38 | * @return builder instance for chain calls.
39 | */
40 | setEntitlementsCacheLifetime(lifetime: EntitlementsCacheLifetime): QonversionConfigBuilder {
41 | this.entitlementsCacheLifetime = lifetime;
42 | return this;
43 | }
44 |
45 | /**
46 | * Provide a listener to be notified about asynchronous user entitlements updates.
47 | *
48 | * Make sure you provide this listener for being up-to-date with the user entitlements.
49 | * Else you can lose some important updates. Also, please, consider that this listener
50 | * should live for the whole lifetime of the application.
51 | *
52 | * @param entitlementsUpdateListener listener to be called when entitlements update.
53 | * @return builder instance for chain calls.
54 | */
55 | setEntitlementsUpdateListener(entitlementsUpdateListener: EntitlementsUpdateListener): QonversionConfigBuilder {
56 | this.entitlementsUpdateListener = entitlementsUpdateListener;
57 | return this;
58 | }
59 |
60 | /**
61 | * Provide a URL to your proxy server which will redirect all the requests from the app
62 | * to our API. Please, contact us before using this feature.
63 | *
64 | * @param url your proxy server url
65 | * @return builder instance for chain calls.
66 | * @see [The documentation](https://documentation.qonversion.io/docs/custom-proxy-server-for-sdks)
67 | */
68 | setProxyURL(url: string): QonversionConfigBuilder {
69 | this.proxyUrl = url;
70 | return this;
71 | }
72 |
73 | /**
74 | * Android only.
75 | * Use this function to enable Qonversion SDK Kids mode.
76 | * With this mode activated, our SDK does not collect any information that violates Google Children’s Privacy Policy.
77 | * @return builder instance for chain calls.
78 | */
79 | enableKidsMode(): QonversionConfigBuilder {
80 | this.kidsMode = true;
81 | return this;
82 | }
83 |
84 | /**
85 | * Generate {@link QonversionConfig} instance with all the provided configurations.
86 | *
87 | * @return the complete {@link QonversionConfig} instance.
88 | */
89 | build(): QonversionConfig {
90 | return new QonversionConfig(
91 | this.projectKey,
92 | this.launchMode,
93 | this.environment,
94 | this.entitlementsCacheLifetime,
95 | this.entitlementsUpdateListener,
96 | this.proxyUrl,
97 | this.kidsMode
98 | )
99 | }
100 | }
101 |
102 | export default QonversionConfigBuilder;
103 |
--------------------------------------------------------------------------------
/src/dto/ActionResult.ts:
--------------------------------------------------------------------------------
1 | import {ActionResultType} from "./enums";
2 | import QonversionError from "./QonversionError";
3 |
4 | class ActionResult {
5 |
6 | type: ActionResultType;
7 | value: Map | undefined;
8 | error: QonversionError | undefined;
9 |
10 | constructor(
11 | type: ActionResultType,
12 | value: Map | undefined,
13 | error: QonversionError | undefined,
14 | ) {
15 | this.type = type;
16 | this.value = value;
17 | this.error = error;
18 | }
19 | }
20 |
21 | export default ActionResult;
22 |
--------------------------------------------------------------------------------
/src/dto/AutomationsDelegate.ts:
--------------------------------------------------------------------------------
1 | import ActionResult from "./ActionResult";
2 |
3 | export interface AutomationsDelegate {
4 |
5 | /**
6 | * Called when Automations' screen is shown.
7 | * @param screenId shown screen id.
8 | */
9 | automationsDidShowScreen(screenId: string): void;
10 |
11 | /**
12 | * Called when Automations flow starts executing an action.
13 | * @param actionResult action that is being executed.
14 | */
15 | automationsDidStartExecuting(actionResult: ActionResult): void;
16 |
17 | /**
18 | * Called when Automations flow fails executing an action.
19 | * @param actionResult failed action.
20 | */
21 | automationsDidFailExecuting(actionResult: ActionResult): void;
22 |
23 | /**
24 | * Called when Automations flow finishes executing an action.
25 | * @param actionResult executed action.
26 | * For instance, if the user made a purchase then action.type = ActionResultType.purchase.
27 | * You can use the {@link QonversionApi.checkEntitlements} method to get available permissions.
28 | */
29 | automationsDidFinishExecuting(actionResult: ActionResult): void;
30 |
31 | /**
32 | * Called when Automations flow is finished and the Automations screen is closed
33 | */
34 | automationsFinished(): void;
35 | }
36 |
--------------------------------------------------------------------------------
/src/dto/AutomationsEvent.ts:
--------------------------------------------------------------------------------
1 | import {AutomationsEventType} from "./enums";
2 |
3 | class AutomationsEvent {
4 |
5 | type: AutomationsEventType;
6 | date: number;
7 |
8 | constructor(
9 | type: AutomationsEventType,
10 | date: number,
11 | ) {
12 | this.type = type;
13 | this.date = date;
14 | }
15 | }
16 |
17 | export default AutomationsEvent;
18 |
--------------------------------------------------------------------------------
/src/dto/Entitlement.ts:
--------------------------------------------------------------------------------
1 | import {EntitlementSource, EntitlementRenewState, EntitlementGrantType} from "./enums";
2 | import Transaction from "./Transaction";
3 |
4 | class Entitlement {
5 | id: string;
6 | productId: string;
7 | isActive: boolean;
8 | renewState: EntitlementRenewState;
9 | source: EntitlementSource;
10 | startedDate: Date;
11 | renewsCount: number;
12 | grantType: EntitlementGrantType;
13 | transactions: Array;
14 | expirationDate?: Date;
15 | trialStartDate?: Date;
16 | firstPurchaseDate?: Date;
17 | lastPurchaseDate?: Date;
18 | autoRenewDisableDate?: Date;
19 | lastActivatedOfferCode?: string;
20 |
21 | constructor(
22 | id: string,
23 | productId: string,
24 | isActive: boolean,
25 | renewState: EntitlementRenewState,
26 | source: EntitlementSource,
27 | startedTimestamp: number,
28 | renewsCount: number,
29 | grantType: EntitlementGrantType,
30 | transactions: Array,
31 | expirationTimestamp: number | undefined,
32 | trialStartTimestamp: number | undefined,
33 | firstPurchaseTimestamp: number | undefined,
34 | lastPurchaseTimestamp: number | undefined,
35 | autoRenewDisableTimestamp: number | undefined,
36 | lastActivatedOfferCode: string | undefined,
37 | ) {
38 | this.id = id;
39 | this.productId = productId;
40 | this.isActive = isActive;
41 | this.renewState = renewState;
42 | this.source = source;
43 | this.startedDate = new Date(startedTimestamp);
44 | this.expirationDate = expirationTimestamp ? new Date(expirationTimestamp) : undefined;
45 | this.renewsCount = renewsCount;
46 | this.grantType = grantType;
47 | this.transactions = transactions;
48 | this.expirationDate = expirationTimestamp ? new Date(expirationTimestamp) : undefined;
49 | this.trialStartDate = trialStartTimestamp ? new Date(trialStartTimestamp) : undefined;
50 | this.firstPurchaseDate = firstPurchaseTimestamp ? new Date(firstPurchaseTimestamp) : undefined;
51 | this.lastPurchaseDate = lastPurchaseTimestamp ? new Date(lastPurchaseTimestamp) : undefined;
52 | this.autoRenewDisableDate = autoRenewDisableTimestamp ? new Date(autoRenewDisableTimestamp) : undefined;
53 | this.lastActivatedOfferCode = lastActivatedOfferCode;
54 | }
55 | }
56 |
57 | export default Entitlement;
58 |
--------------------------------------------------------------------------------
/src/dto/EntitlementsUpdateListener.ts:
--------------------------------------------------------------------------------
1 | import Entitlement from './Entitlement';
2 |
3 | export interface EntitlementsUpdateListener {
4 |
5 | /**
6 | * Called when entitlements update.
7 | * For example, when pending purchases like SCA, Ask to buy, etc., happen.
8 | * @param entitlements all the client's entitlements after update.
9 | */
10 | onEntitlementsUpdated(entitlements: Map): void;
11 | }
12 |
--------------------------------------------------------------------------------
/src/dto/Experiment.ts:
--------------------------------------------------------------------------------
1 | import ExperimentGroup from "./ExperimentGroup";
2 |
3 | class Experiment {
4 | id: string;
5 | name: string;
6 | group: ExperimentGroup;
7 |
8 | constructor(id: string, name: string, group: ExperimentGroup) {
9 | this.id = id;
10 | this.name = name;
11 | this.group = group;
12 | }
13 | }
14 |
15 | export default Experiment;
16 |
--------------------------------------------------------------------------------
/src/dto/ExperimentGroup.ts:
--------------------------------------------------------------------------------
1 | import { ExperimentGroupType } from "./enums";
2 |
3 | class ExperimentGroup {
4 | id: string;
5 | name: string;
6 | type: ExperimentGroupType;
7 |
8 | constructor(id: string, name: string, type: ExperimentGroupType) {
9 | this.id = id;
10 | this.name = name;
11 | this.type = type;
12 | }
13 | }
14 |
15 | export default ExperimentGroup;
16 |
--------------------------------------------------------------------------------
/src/dto/IntroEligibility.ts:
--------------------------------------------------------------------------------
1 | import { IntroEligibilityStatus } from "./enums";
2 |
3 | class IntroEligibility {
4 | status?: IntroEligibilityStatus;
5 |
6 | constructor(status: IntroEligibilityStatus | undefined) {
7 | this.status = status;
8 | }
9 | }
10 |
11 | export default IntroEligibility;
12 |
--------------------------------------------------------------------------------
/src/dto/Offering.ts:
--------------------------------------------------------------------------------
1 | import { OfferingTags } from "./enums";
2 | import Product from "./Product";
3 |
4 | class Offering {
5 | id: string;
6 | tag: OfferingTags;
7 | products: Array;
8 |
9 | constructor(id: string, tag: OfferingTags, products: Product[]) {
10 | this.id = id;
11 | this.tag = tag;
12 | this.products = products;
13 | }
14 |
15 | productForIdentifier(identifier: string): Product | undefined {
16 | return this.products.find((object) => object.qonversionID === identifier);
17 | }
18 | }
19 |
20 | export default Offering;
21 |
--------------------------------------------------------------------------------
/src/dto/Offerings.ts:
--------------------------------------------------------------------------------
1 | import Offering from "./Offering";
2 |
3 | class Offerings {
4 | main: Offering | null;
5 | availableOffering: Array;
6 |
7 | constructor(main: Offering | null, availableOfferings: Array) {
8 | this.main = main;
9 | this.availableOffering = availableOfferings;
10 | }
11 |
12 | offeringForIdentifier(identifier: string): Offering | undefined {
13 | return this.availableOffering.find((object) => object.id === identifier);
14 | }
15 | }
16 |
17 | export default Offerings;
18 |
--------------------------------------------------------------------------------
/src/dto/Product.ts:
--------------------------------------------------------------------------------
1 | import {ProductType, PurchaseUpdatePolicy} from "./enums";
2 | import SKProduct from "./storeProducts/SKProduct";
3 | import SkuDetails from "./storeProducts/SkuDetails";
4 | import ProductStoreDetails from "./storeProducts/ProductStoreDetails";
5 | import ProductOfferDetails from './storeProducts/ProductOfferDetails';
6 | import PurchaseModel from './PurchaseModel';
7 | import PurchaseUpdateModel from './PurchaseUpdateModel';
8 | import SubscriptionPeriod from './SubscriptionPeriod';
9 |
10 | class Product {
11 | qonversionID: string;
12 | storeID: string | null;
13 |
14 | /**
15 | * Identifier of the base plan for Google product.
16 | */
17 | basePlanID: string | null;
18 |
19 | /**
20 | * Google Play Store details of this product.
21 | * Android only. Null for iOS, or if the product was not found.
22 | * Doesn't take into account {@link basePlanID}.
23 | * @deprecated Consider using {@link storeDetails} instead.
24 | */
25 | skuDetails: SkuDetails | null;
26 |
27 | /**
28 | * Google Play Store details of this product.
29 | * Android only. Null for iOS, or if the product was not found.
30 | */
31 | storeDetails: ProductStoreDetails | null;
32 |
33 | /**
34 | * App store details of this product.
35 | * iOS only. Null for Android, or if the product was not found.
36 | */
37 | skProduct: SKProduct | null;
38 |
39 | offeringId?: string | null;
40 |
41 | /**
42 | * For Android - the subscription base plan duration. If the {@link basePlanID} is not specified,
43 | * the duration is calculated using the deprecated {@link skuDetails}.
44 | * For iOS - the duration of the {@link skProduct}.
45 | * Null, if it's not a subscription product or the product was not found in the store.
46 | */
47 | subscriptionPeriod: SubscriptionPeriod | null;
48 |
49 | /**
50 | * The subscription trial duration of the default offer for Android or of the product for iOS.
51 | * See {@link ProductStoreDetails.defaultSubscriptionOfferDetails} for the information on how we
52 | * choose the default offer for Android.
53 | * Null, if it's not a subscription product or the product was not found the store.
54 | */
55 | trialPeriod: SubscriptionPeriod | null;
56 |
57 | /**
58 | * The calculated type of this product based on the store information.
59 | * On Android uses deprecated {@link skuDetails} for the old subscription products
60 | * where {@link basePlanID} is not specified, and {@link storeDetails} for all the other products.
61 | * On iOS uses {@link skProduct} information.
62 | */
63 | type: ProductType;
64 |
65 | /**
66 | * Formatted price of for this product, including the currency sign.
67 | */
68 | prettyPrice: string | null;
69 |
70 | price?: number;
71 | currencyCode?: string;
72 | storeTitle?: string;
73 | storeDescription?: string;
74 | prettyIntroductoryPrice?: string;
75 |
76 | constructor(
77 | qonversionID: string,
78 | storeID: string,
79 | basePlanID: string | null,
80 | skuDetails: SkuDetails | null,
81 | storeDetails: ProductStoreDetails | null,
82 | skProduct: SKProduct | null,
83 | offeringId: string | null,
84 | subscriptionPeriod: SubscriptionPeriod | null,
85 | trialPeriod: SubscriptionPeriod | null,
86 | type: ProductType,
87 | prettyPrice: string | null,
88 | price: number | undefined,
89 | currencyCode: string | undefined,
90 | storeTitle: string | undefined,
91 | storeDescription: string | undefined,
92 | prettyIntroductoryPrice: string | undefined,
93 | ) {
94 | this.qonversionID = qonversionID;
95 | this.storeID = storeID;
96 | this.basePlanID = basePlanID;
97 | this.skuDetails = skuDetails;
98 | this.storeDetails = storeDetails;
99 | this.skProduct = skProduct;
100 | this.offeringId = offeringId;
101 | this.subscriptionPeriod = subscriptionPeriod;
102 | this.trialPeriod = trialPeriod;
103 | this.type = type;
104 | this.prettyPrice = prettyPrice;
105 | this.price = price;
106 | this.currencyCode = currencyCode;
107 | this.storeTitle = storeTitle;
108 | this.storeDescription = storeDescription;
109 | this.prettyIntroductoryPrice = prettyIntroductoryPrice;
110 | }
111 |
112 | /**
113 | * Converts this product to purchase model to pass to {@link Qonversion.purchase}.
114 | * @param offerId concrete Android offer identifier if necessary.
115 | * If the products' base plan id is specified, but offer id is not provided for
116 | * purchase, then default offer will be used.
117 | * Ignored if base plan id is not specified.
118 | * Ignored for iOS.
119 | * To know how we choose the default offer, see {@link ProductStoreDetails.defaultSubscriptionOfferDetails}.
120 | * @returns purchase model to pass to the purchase method.
121 | */
122 | toPurchaseModel(offerId: string | null = null): PurchaseModel {
123 | return new PurchaseModel(this.qonversionID, offerId);
124 | }
125 |
126 | /**
127 | * Converts this product to purchase model to pass to {@link Qonversion.purchase}.
128 | * @param offer concrete Android offer which you'd like to purchase.
129 | * @return purchase model to pass to the purchase method.
130 | */
131 | toPurchaseModelWithOffer(offer: ProductOfferDetails): PurchaseModel {
132 | const model = this.toPurchaseModel(offer.offerId);
133 | // Remove offer for the case when provided offer details are for bare base plan.
134 | if (offer.offerId == null) {
135 | model.removeOffer();
136 | }
137 |
138 | return model;
139 | }
140 |
141 | /**
142 | * Android only.
143 | *
144 | * Converts this product to purchase update (upgrade/downgrade) model
145 | * to pass to {@link Qonversion.updatePurchase}.
146 | * @param oldProductId Qonversion product identifier from which the upgrade/downgrade
147 | * will be initialized.
148 | * @param updatePolicy purchase update policy.
149 | * @return purchase model to pass to the update purchase method.
150 | */
151 | toPurchaseUpdateModel(
152 | oldProductId: string,
153 | updatePolicy: PurchaseUpdatePolicy | null = null
154 | ): PurchaseUpdateModel {
155 | return new PurchaseUpdateModel(this.qonversionID, oldProductId, updatePolicy);
156 | }
157 | }
158 |
159 | export default Product;
160 |
--------------------------------------------------------------------------------
/src/dto/PromoPurchasesListener.ts:
--------------------------------------------------------------------------------
1 | import Entitlement from './Entitlement';
2 |
3 | export interface PromoPurchasesListener {
4 |
5 | /**
6 | * Fired each time a promo purchase from the App Store happens.
7 | * Call {@param promoPurchaseExecutor} in case of your app is ready to start promo purchase.
8 | * Or cache that executor and call later when you need.
9 | * @param productId StoreKit product identifier.
10 | * @param promoPurchaseExecutor a function that will start a promo purchase flow.
11 | */
12 | onPromoPurchaseReceived(productId: string, promoPurchaseExecutor: () => Promise>): void;
13 | }
14 |
--------------------------------------------------------------------------------
/src/dto/PromotionalOffer.ts:
--------------------------------------------------------------------------------
1 | import SKProductDiscount from './storeProducts/SKProductDiscount';
2 | import SKPaymentDiscount from './storeProducts/SKPaymentDiscount';
3 |
4 | class PromotionalOffer {
5 | public readonly productDiscount: SKProductDiscount;
6 | public readonly paymentDiscount: SKPaymentDiscount;
7 |
8 | constructor (
9 | productDiscount: SKProductDiscount,
10 | paymentDiscount: SKPaymentDiscount
11 | ) {
12 | this.productDiscount = productDiscount;
13 | this.paymentDiscount = paymentDiscount;
14 | }
15 | }
16 |
17 | export default PromotionalOffer;
18 |
--------------------------------------------------------------------------------
/src/dto/PurchaseModel.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Used to provide all the necessary purchase data to the {@link Qonversion.purchase} method.
3 | * Can be created manually or using the {@link Product.toPurchaseModel} method.
4 | *
5 | * If {@link offerId} is not specified for Android, then the default offer will be applied.
6 | * To know how we choose the default offer, see {@link ProductStoreDetails.defaultSubscriptionOfferDetails}.
7 | *
8 | * If you want to remove any intro/trial offer from the purchase on Android (use only a bare base plan),
9 | * call the {@link removeOffer} method.
10 | */
11 | class PurchaseModel {
12 |
13 | public readonly productId: string;
14 | public offerId: string | null = null;
15 |
16 | public applyOffer: boolean = true;
17 |
18 | constructor(productId: string, offerId: string | null = null) {
19 | this.productId = productId;
20 | this.offerId = offerId;
21 | }
22 |
23 | removeOffer(): PurchaseModel {
24 | this.applyOffer = false;
25 | return this;
26 | }
27 | }
28 |
29 | export default PurchaseModel;
30 |
--------------------------------------------------------------------------------
/src/dto/PurchaseOptions.ts:
--------------------------------------------------------------------------------
1 | import Product from "./Product";
2 | import {PurchaseUpdatePolicy} from "./enums";
3 | import PromotionalOffer from './PromotionalOffer';
4 |
5 | class PurchaseOptions {
6 | public readonly offerId: string | null;
7 | public readonly applyOffer: boolean;
8 | public readonly oldProduct: Product | null;
9 | public readonly updatePolicy: PurchaseUpdatePolicy | null;
10 | public readonly contextKeys: string[] | null;
11 | public readonly quantity: number;
12 | public readonly promotionalOffer: PromotionalOffer | null;
13 |
14 | constructor (
15 | offerId: string | null,
16 | applyOffer: boolean,
17 | oldProduct: Product | null,
18 | updatePolicy: PurchaseUpdatePolicy | null,
19 | contextKeys: string[] | null,
20 | quantity: number,
21 | promotionalOffer: PromotionalOffer | null
22 | ) {
23 | this.offerId = offerId;
24 | this.applyOffer = applyOffer;
25 | this.oldProduct = oldProduct;
26 | this.updatePolicy = updatePolicy;
27 | this.contextKeys = contextKeys;
28 | this.quantity = quantity;
29 | this.promotionalOffer = promotionalOffer;
30 | }
31 | }
32 |
33 | export default PurchaseOptions;
34 |
--------------------------------------------------------------------------------
/src/dto/PurchaseOptionsBuilder.ts:
--------------------------------------------------------------------------------
1 | import Product from "./Product";
2 | import {PurchaseUpdatePolicy} from "./enums";
3 | import ProductOfferDetails from "./storeProducts/ProductOfferDetails";
4 | import PurchaseOptions from "./PurchaseOptions";
5 | import PromotionalOffer from "./PromotionalOffer";
6 |
7 | class PurchaseOptionsBuilder {
8 | private offerId: string | null = null;
9 | private applyOffer: boolean = true;
10 | private oldProduct: Product | null = null;
11 | private updatePolicy: PurchaseUpdatePolicy | null = null;
12 | private contextKeys: string[] | null = null;
13 | private quantity: number = 1;
14 | private promoOffer: PromotionalOffer | null = null;
15 |
16 | /**
17 | * iOS only.
18 | * Set quantity of product purchasing. Use for consumable in-app products.
19 | * @param quantity of product purchasing.
20 | * @return builder instance for chain calls.
21 | */
22 | setQuantity(quantity: number): PurchaseOptionsBuilder {
23 | this.quantity = quantity;
24 | return this;
25 | }
26 |
27 | /**
28 | * Android only.
29 | * Set offer for the purchase.
30 | * If offer is not specified, then the default offer will be applied. To know how we choose
31 | * the default offer, see {@link ProductStoreDetails.defaultSubscriptionOfferDetails}.
32 | * @param offer concrete offer which you'd like to purchase.
33 | * @return builder instance for chain calls.
34 | */
35 | setOffer(offer: ProductOfferDetails) {
36 | this.offerId = offer.offerId;
37 | return this;
38 | }
39 |
40 | /**
41 | * Android only.
42 | * Set the offer Id to the purchase.
43 | * If {@link offerId} is not specified, then the default offer will be applied. To know how we choose
44 | * the default offer, see {@link ProductStoreDetails.defaultSubscriptionOfferDetails}.
45 | * @param offerId concrete offer Id which you'd like to purchase.
46 | * @return builder instance for chain calls.
47 | */
48 | setOfferId(offerId: string): PurchaseOptionsBuilder {
49 | this.offerId = offerId;
50 | return this;
51 | }
52 |
53 | /**
54 | * Android only.
55 | * Call this function to remove any intro/trial offer from the purchase (use only a bare base plan).
56 | * @return builder instance for chain calls.
57 | */
58 | removeOffer(): PurchaseOptionsBuilder {
59 | this.applyOffer = false;
60 | return this;
61 | }
62 |
63 | /**
64 | * Android only.
65 | * Set Qonversion product from which the upgrade/downgrade will be initialized.
66 | *
67 | * @param oldProduct Qonversion product from which the upgrade/downgrade
68 | * will be initialized.
69 | * @return builder instance for chain calls.
70 | */
71 | setOldProduct(oldProduct: Product): PurchaseOptionsBuilder {
72 | this.oldProduct = oldProduct;
73 | return this;
74 | }
75 |
76 | /**
77 | * Android only.
78 | * Set the update policy for the purchase.
79 | * If the {@link updatePolicy} is not provided, then default one
80 | * will be selected - {@link PurchaseUpdatePolicy.WITH_TIME_PRORATION}.
81 | * @param updatePolicy update policy for the purchase.
82 | * @return builder instance for chain calls.
83 | */
84 | setUpdatePolicy(updatePolicy: PurchaseUpdatePolicy): PurchaseOptionsBuilder {
85 | this.updatePolicy = updatePolicy;
86 | return this;
87 | }
88 |
89 | /**
90 | * Set the context keys associated with a purchase.
91 | *
92 | * @param contextKeys context keys for the purchase.
93 | * @return builder instance for chain calls.
94 | */
95 | setContextKeys(contextKeys: string[]): PurchaseOptionsBuilder {
96 | this.contextKeys = contextKeys;
97 | return this;
98 | }
99 |
100 | /**
101 | * Set the promotional offer details.
102 | *
103 | * @param promoOffer promotional offer details.
104 | * @return builder instance for chain calls.
105 | */
106 | setPromotionalOffer(promoOffer: PromotionalOffer): PurchaseOptionsBuilder {
107 | this.promoOffer = promoOffer;
108 | return this;
109 | }
110 |
111 | /**
112 | * Generate {@link PurchaseOptions} instance with all the provided options.
113 | * @return the complete {@link PurchaseOptions} instance.
114 | */
115 | build(): PurchaseOptions {
116 | return new PurchaseOptions(
117 | this.offerId,
118 | this.applyOffer,
119 | this.oldProduct,
120 | this.updatePolicy,
121 | this.contextKeys,
122 | this.quantity,
123 | this.promoOffer);
124 | }
125 | }
126 |
127 | export default PurchaseOptionsBuilder;
128 |
--------------------------------------------------------------------------------
/src/dto/PurchaseUpdateModel.ts:
--------------------------------------------------------------------------------
1 | import {PurchaseUpdatePolicy} from './enums';
2 |
3 | /**
4 | * Used to provide all the necessary purchase data to the {@link Qonversion.updatePurchase} method.
5 | * Can be created manually or using the {@link Product.toPurchaseUpdateModel} method.
6 | *
7 | * Requires Qonversion product identifiers - {@link productId} for the purchasing one and
8 | * {@link oldProductId} for the purchased one.
9 | *
10 | * If {@link offerId} is not specified for Android, then the default offer will be applied.
11 | * To know how we choose the default offer, see {@link ProductStoreDetails.defaultSubscriptionOfferDetails}.
12 | *
13 | * If you want to remove any intro/trial offer from the purchase on Android (use only a bare base plan),
14 | * call the {@link removeOffer} method.
15 | */
16 | class PurchaseUpdateModel {
17 |
18 | public readonly productId: string;
19 | public readonly oldProductId: string;
20 | public updatePolicy: PurchaseUpdatePolicy | null = null;
21 | public offerId: string | null = null;
22 |
23 | public applyOffer: boolean = true;
24 |
25 | constructor(
26 | productId: string,
27 | oldProductId: string,
28 | updatePolicy: PurchaseUpdatePolicy | null = null,
29 | offerId: string | null = null,
30 | ) {
31 | this.productId = productId;
32 | this.oldProductId = oldProductId;
33 | this.updatePolicy = updatePolicy;
34 | this.offerId = offerId;
35 | }
36 |
37 | removeOffer(): PurchaseUpdateModel {
38 | this.applyOffer = false;
39 | return this;
40 | }
41 | }
42 |
43 | export default PurchaseUpdateModel;
44 |
--------------------------------------------------------------------------------
/src/dto/QonversionError.ts:
--------------------------------------------------------------------------------
1 | import {QonversionErrorCode} from './enums';
2 |
3 | class QonversionError {
4 | code: QonversionErrorCode;
5 | domain?: string;
6 | description: string;
7 | additionalMessage: string;
8 |
9 | constructor(
10 | code: QonversionErrorCode,
11 | description: string,
12 | additionalMessage: string,
13 | domain?: string,
14 | ) {
15 | this.code = code;
16 | this.domain = domain;
17 | this.description = description;
18 | this.additionalMessage = additionalMessage;
19 | }
20 | }
21 |
22 | export default QonversionError;
23 |
--------------------------------------------------------------------------------
/src/dto/RemoteConfig.ts:
--------------------------------------------------------------------------------
1 | import Experiment from "./Experiment";
2 | import RemoteConfigurationSource from "./RemoteConfigurationSource";
3 |
4 | class RemoteConfig {
5 | payload: Record;
6 | experiment?: Experiment | null;
7 | source: RemoteConfigurationSource;
8 |
9 | constructor(payload: Record, experiment: Experiment | null, source: RemoteConfigurationSource) {
10 | this.payload = payload;
11 | this.experiment = experiment;
12 | this.source = source;
13 | }
14 | }
15 |
16 | export default RemoteConfig;
17 |
--------------------------------------------------------------------------------
/src/dto/RemoteConfigList.ts:
--------------------------------------------------------------------------------
1 | import RemoteConfig from './RemoteConfig';
2 |
3 | class RemoteConfigList {
4 | remoteConfigs: Array;
5 |
6 | constructor(remoteConfigs: Array) {
7 | this.remoteConfigs = remoteConfigs;
8 | }
9 |
10 | remoteConfigForContextKey(contextKey: string): RemoteConfig | undefined {
11 | return this.findRemoteConfigForContextKey(contextKey);
12 | }
13 |
14 | remoteConfigForEmptyContextKey(): RemoteConfig | undefined {
15 | return this.findRemoteConfigForContextKey(null);
16 | }
17 |
18 | private findRemoteConfigForContextKey(contextKey: string | null): RemoteConfig | undefined {
19 | return this.remoteConfigs.find(config => config.source.contextKey == contextKey);
20 | }
21 | }
22 |
23 | export default RemoteConfigList;
24 |
--------------------------------------------------------------------------------
/src/dto/RemoteConfigurationSource.ts:
--------------------------------------------------------------------------------
1 | import {RemoteConfigurationAssignmentType, RemoteConfigurationSourceType} from "./enums";
2 |
3 |
4 | class RemoteConfigurationSource {
5 | id: string;
6 | name: string;
7 | type: RemoteConfigurationSourceType;
8 | assignmentType: RemoteConfigurationAssignmentType;
9 | contextKey: string | null;
10 |
11 | constructor(
12 | id: string,
13 | name: string,
14 | type: RemoteConfigurationSourceType,
15 | assignmentType: RemoteConfigurationAssignmentType,
16 | contextKey: string | null,
17 | ) {
18 | this.id = id;
19 | this.name = name;
20 | this.type = type;
21 | this.assignmentType = assignmentType;
22 | this.contextKey = contextKey;
23 | }
24 | }
25 |
26 | export default RemoteConfigurationSource;
27 |
--------------------------------------------------------------------------------
/src/dto/ScreenPresentationConfig.ts:
--------------------------------------------------------------------------------
1 | import {ScreenPresentationStyle} from './enums';
2 |
3 | export class ScreenPresentationConfig {
4 | /**
5 | * Describes how screens will be displayed.
6 | * For mode details see the enum description.
7 | */
8 | presentationStyle: ScreenPresentationStyle;
9 |
10 | /**
11 | * iOS only. For Android consider using {@link ScreenPresentationStyle.NO_ANIMATION}.
12 | *
13 | * Describes whether should transaction be animated or not.
14 | * Default value is true.
15 | */
16 | animated: boolean;
17 |
18 | constructor(presentationStyle: ScreenPresentationStyle, animated?: boolean) {
19 | this.presentationStyle = presentationStyle;
20 | this.animated = animated === undefined ? true : animated;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/dto/SubscriptionPeriod.ts:
--------------------------------------------------------------------------------
1 | import {SubscriptionPeriodUnit} from "./enums";
2 |
3 | /**
4 | * A class describing a subscription period
5 | */
6 | class SubscriptionPeriod {
7 | /**
8 | * A count of subsequent intervals.
9 | */
10 | unitCount: number;
11 |
12 | /**
13 | * Interval unit.
14 | */
15 | unit: SubscriptionPeriodUnit;
16 |
17 | /**
18 | * ISO 8601 representation of the period, e.g. "P7D", meaning 7 days period.
19 | */
20 | iso: string;
21 |
22 | constructor(
23 | unitCount: number,
24 | unit: SubscriptionPeriodUnit,
25 | iso: string,
26 | ) {
27 | this.unitCount = unitCount;
28 | this.unit = unit;
29 | this.iso = iso;
30 | }
31 | }
32 |
33 | export default SubscriptionPeriod;
34 |
--------------------------------------------------------------------------------
/src/dto/Transaction.ts:
--------------------------------------------------------------------------------
1 | import {TransactionEnvironment, TransactionOwnershipType, TransactionType} from "./enums";
2 |
3 | class Transaction {
4 | originalTransactionId: string;
5 | transactionId: string;
6 | transactionDate: Date;
7 | environment: TransactionEnvironment;
8 | ownershipType: TransactionOwnershipType;
9 | type: TransactionType;
10 | expirationDate?: Date;
11 | transactionRevocationDate?: Date;
12 | offerCode?: string;
13 | promoOfferId?: string;
14 |
15 | constructor(
16 | originalTransactionId: string,
17 | transactionId: string,
18 | transactionTimestamp: number,
19 | environment: TransactionEnvironment,
20 | ownershipType: TransactionOwnershipType,
21 | type: TransactionType,
22 | expirationTimestamp: number | undefined,
23 | transactionRevocationTimestamp: number | undefined,
24 | offerCode: string | undefined,
25 | promoOfferId: string | undefined,
26 | ) {
27 | this.originalTransactionId = originalTransactionId;
28 | this.transactionId = transactionId;
29 | this.transactionDate = new Date(transactionTimestamp);
30 | this.environment = environment;
31 | this.ownershipType = ownershipType;
32 | this.type = type;
33 | this.expirationDate = expirationTimestamp ? new Date(expirationTimestamp) : undefined;
34 | this.transactionRevocationDate = transactionRevocationTimestamp ? new Date(transactionRevocationTimestamp) : undefined;
35 | this.offerCode = offerCode;
36 | this.promoOfferId = promoOfferId;
37 | }
38 | }
39 |
40 | export default Transaction;
41 |
--------------------------------------------------------------------------------
/src/dto/User.ts:
--------------------------------------------------------------------------------
1 | class User {
2 | qonversionId: string;
3 | identityId?: string | null;
4 |
5 | constructor(qonversionId: string, identityId?: string | null) {
6 | this.qonversionId = qonversionId;
7 | this.identityId = identityId;
8 | }
9 | }
10 |
11 | export default User;
12 |
--------------------------------------------------------------------------------
/src/dto/UserProperties.ts:
--------------------------------------------------------------------------------
1 | import UserProperty from './UserProperty';
2 | import {UserPropertyKey} from './enums';
3 |
4 | class UserProperties {
5 | /**
6 | * List of all user properties.
7 | */
8 | properties: UserProperty[];
9 |
10 | /**
11 | * List of user properties, set for the Qonversion defined keys.
12 | * This is a subset of all {@link properties} list.
13 | * See {@link QonversionApi.setUserProperty}.
14 | */
15 | definedProperties: UserProperty[];
16 |
17 | /**
18 | * List of user properties, set for custom keys.
19 | * This is a subset of all {@link properties} list.
20 | * See {@link QonversionApi.setCustomUserProperty}.
21 | */
22 | customProperties: UserProperty[];
23 |
24 | /**
25 | * Map of all user properties.
26 | * This is a flattened version of the {@link properties} list as a key-value map.
27 | */
28 | flatPropertiesMap: Map;
29 |
30 | /**
31 | * Map of user properties, set for the Qonversion defined keys.
32 | * This is a flattened version of the {@link definedProperties} list as a key-value map.
33 | * See {@link QonversionApi.setUserProperty}.
34 | */
35 | flatDefinedPropertiesMap: Map;
36 |
37 | /**
38 | * Map of user properties, set for custom keys.
39 | * This is a flattened version of the {@link customProperties} list as a key-value map.
40 | * See {@link QonversionApi.setCustomUserProperty}.
41 | */
42 | flatCustomPropertiesMap: Map;
43 |
44 | constructor(properties: UserProperty[]) {
45 | this.properties = properties;
46 | this.definedProperties = properties.filter(property => property.definedKey !== UserPropertyKey.CUSTOM);
47 | this.customProperties = properties.filter(property => property.definedKey === UserPropertyKey.CUSTOM);
48 |
49 | this.flatPropertiesMap = new Map();
50 | this.flatDefinedPropertiesMap = new Map();
51 | this.flatCustomPropertiesMap = new Map();
52 | properties.forEach(property => {
53 | this.flatPropertiesMap.set(property.key, property.value);
54 | if (property.definedKey == UserPropertyKey.CUSTOM) {
55 | this.flatCustomPropertiesMap.set(property.key, property.value);
56 | } else {
57 | this.flatDefinedPropertiesMap.set(property.definedKey, property.value);
58 | }
59 | });
60 | }
61 |
62 | /**
63 | * Searches for a property with the given property {@link key} in all properties list.
64 | */
65 | getProperty(key: string): UserProperty | undefined {
66 | return this.properties.find(userProperty => userProperty.key == key);
67 | }
68 |
69 | /**
70 | * Searches for a property with the given Qonversion defined property {@link key}
71 | * in defined properties list.
72 | */
73 | getDefinedProperty(key: UserPropertyKey): UserProperty | undefined {
74 | return this.definedProperties.find(userProperty => userProperty.definedKey == key);
75 | }
76 | }
77 |
78 | export default UserProperties;
79 |
--------------------------------------------------------------------------------
/src/dto/UserProperty.ts:
--------------------------------------------------------------------------------
1 | import {UserPropertyKey} from './enums';
2 | import mapper from '../internal/Mapper';
3 |
4 | class UserProperty {
5 | key: string;
6 | value: string;
7 |
8 | /**
9 | * {@link UserPropertyKey} used to set this property.
10 | * Returns {@link UserPropertyKey.CUSTOM} for custom properties.
11 | */
12 | definedKey: UserPropertyKey;
13 |
14 | constructor(key: string, value: string) {
15 | this.key = key;
16 | this.value = value;
17 | this.definedKey = mapper.convertDefinedUserPropertyKey(key);
18 | }
19 | }
20 |
21 | export default UserProperty;
22 |
--------------------------------------------------------------------------------
/src/dto/storeProducts/ProductInAppDetails.ts:
--------------------------------------------------------------------------------
1 | import ProductPrice from "./ProductPrice";
2 |
3 | /**
4 | * This class contains all the information about the Google in-app product details.
5 | */
6 | class ProductInAppDetails {
7 | /**
8 | * The price of the in-app product.
9 | */
10 | price: ProductPrice;
11 |
12 | constructor(price: ProductPrice) {
13 | this.price = price;
14 | }
15 | }
16 |
17 | export default ProductInAppDetails;
18 |
--------------------------------------------------------------------------------
/src/dto/storeProducts/ProductInstallmentPlanDetails.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This class represents the details about the installment plan for a subscription product.
3 | */
4 | class ProductInstallmentPlanDetails {
5 | /**
6 | * Committed payments count after a user signs up for this subscription plan.
7 | */
8 | commitmentPaymentsCount: number;
9 |
10 | /**
11 | * Subsequent committed payments count after this subscription plan renews.
12 | *
13 | * Returns 0 if the installment plan doesn't have any subsequent commitment,
14 | * which means this subscription plan will fall back to a normal
15 | * non-installment monthly plan when the plan renews.
16 | */
17 | subsequentCommitmentPaymentsCount: number;
18 |
19 | constructor(
20 | commitmentPaymentsCount: number,
21 | subsequentCommitmentPaymentsCount: number
22 | ) {
23 | this.commitmentPaymentsCount = commitmentPaymentsCount;
24 | this.subsequentCommitmentPaymentsCount = subsequentCommitmentPaymentsCount;
25 | }
26 | }
27 |
28 | export default ProductInstallmentPlanDetails;
29 |
--------------------------------------------------------------------------------
/src/dto/storeProducts/ProductOfferDetails.ts:
--------------------------------------------------------------------------------
1 | import ProductPricingPhase from "./ProductPricingPhase";
2 | import ProductInstallmentPlanDetails from './ProductInstallmentPlanDetails';
3 |
4 | /**
5 | * This class contains all the information about the Google subscription offer details.
6 | * It might be either a plain base plan details or a base plan with the concrete offer details.
7 | */
8 | class ProductOfferDetails {
9 | /**
10 | * The identifier of the current base plan.
11 | */
12 | basePlanId: string;
13 |
14 | /**
15 | * The identifier of the concrete offer, to which these details belong.
16 | * Null, if these are plain base plan details.
17 | */
18 | offerId: string | null;
19 |
20 | /**
21 | * A token to purchase the current offer.
22 | */
23 | offerToken: string;
24 |
25 | /**
26 | * List of tags set for the current offer.
27 | */
28 | tags: string[];
29 |
30 | /**
31 | * A time-ordered list of pricing phases for the current offer.
32 | */
33 | pricingPhases: ProductPricingPhase[];
34 |
35 | /**
36 | * A base plan phase details.
37 | */
38 | basePlan: ProductPricingPhase | null;
39 |
40 | /**
41 | * Additional details of an installment plan, if exists.
42 | */
43 | installmentPlanDetails: ProductInstallmentPlanDetails | null;
44 |
45 | /**
46 | * A trial phase details, if exists.
47 | */
48 | introPhase: ProductPricingPhase | null;
49 |
50 | /**
51 | * An intro phase details, if exists.
52 | * The intro phase is one of single or recurrent discounted payments.
53 | */
54 | trialPhase: ProductPricingPhase | null;
55 |
56 | /**
57 | * True, if there is a trial phase in the current offer. False otherwise.
58 | */
59 | hasTrial: boolean;
60 |
61 | /**
62 | * True, if there is any intro phase in the current offer. False otherwise.
63 | * The intro phase is one of single or recurrent discounted payments.
64 | */
65 | hasIntro: boolean;
66 |
67 | /**
68 | * True, if there is any trial or intro phase in the current offer. False otherwise.
69 | * The intro phase is one of single or recurrent discounted payments.
70 | */
71 | hasTrialOrIntro: boolean;
72 |
73 | constructor(
74 | basePlanId: string,
75 | offerId: string | null,
76 | offerToken: string,
77 | tags: string[],
78 | pricingPhases: ProductPricingPhase[],
79 | basePlan: ProductPricingPhase | null,
80 | installmentPlanDetails: ProductInstallmentPlanDetails | null,
81 | introPhase: ProductPricingPhase | null,
82 | trialPhase: ProductPricingPhase | null,
83 | hasTrial: boolean,
84 | hasIntro: boolean,
85 | hasTrialOrIntro: boolean,
86 | ) {
87 | this.basePlanId = basePlanId;
88 | this.offerId = offerId;
89 | this.offerToken = offerToken;
90 | this.tags = tags;
91 | this.pricingPhases = pricingPhases;
92 | this.basePlan = basePlan;
93 | this.installmentPlanDetails = installmentPlanDetails;
94 | this.introPhase = introPhase;
95 | this.trialPhase = trialPhase;
96 | this.hasTrial = hasTrial;
97 | this.hasIntro = hasIntro;
98 | this.hasTrialOrIntro = hasTrialOrIntro;
99 | }
100 | }
101 |
102 | export default ProductOfferDetails;
103 |
--------------------------------------------------------------------------------
/src/dto/storeProducts/ProductPrice.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Information about the Google product's price.
3 | */
4 | class ProductPrice {
5 | /**
6 | * Total amount of money in micro-units,
7 | * where 1,000,000 micro-units equal one unit of the currency.
8 | */
9 | priceAmountMicros: number;
10 |
11 | /**
12 | * ISO 4217 currency code for price.
13 | */
14 | priceCurrencyCode: string;
15 |
16 | /**
17 | * Formatted price for the payment, including its currency sign.
18 | */
19 | formattedPrice: string;
20 |
21 | /**
22 | * True, if the price is zero. False otherwise.
23 | */
24 | isFree: boolean;
25 |
26 | /**
27 | * Price currency symbol. Null if failed to parse.
28 | */
29 | currencySymbol: string | null;
30 |
31 | constructor(
32 | priceAmountMicros: number,
33 | priceCurrencyCode: string,
34 | formattedPrice: string,
35 | isFree: boolean,
36 | currencySymbol: string | null = null
37 | ) {
38 | this.priceAmountMicros = priceAmountMicros;
39 | this.priceCurrencyCode = priceCurrencyCode;
40 | this.formattedPrice = formattedPrice;
41 | this.isFree = isFree;
42 | this.currencySymbol = currencySymbol;
43 | }
44 | }
45 |
46 | export default ProductPrice;
47 |
--------------------------------------------------------------------------------
/src/dto/storeProducts/ProductPricingPhase.ts:
--------------------------------------------------------------------------------
1 | import SubscriptionPeriod from "../SubscriptionPeriod";
2 | import ProductPrice from "./ProductPrice";
3 | import {PricingPhaseRecurrenceMode, PricingPhaseType} from "../enums";
4 |
5 | /**
6 | * This class represents a pricing phase, describing how a user pays at a point in time.
7 | */
8 | class ProductPricingPhase {
9 | /**
10 | * Price for the current phase.
11 | */
12 | price: ProductPrice;
13 |
14 | /**
15 | * The billing period for which the given price applies.
16 | */
17 | billingPeriod: SubscriptionPeriod;
18 |
19 | /**
20 | * Number of cycles for which the billing period is applied.
21 | */
22 | billingCycleCount: number;
23 |
24 | /**
25 | * Recurrence mode for the pricing phase.
26 | */
27 | recurrenceMode: PricingPhaseRecurrenceMode;
28 |
29 | /**
30 | * Type of the pricing phase.
31 | */
32 | type: PricingPhaseType;
33 |
34 | /**
35 | * True, if the current phase is a trial period. False otherwise.
36 | */
37 | isTrial: boolean;
38 |
39 | /**
40 | * True, if the current phase is an intro period. False otherwise.
41 | * The intro phase is one of single or recurrent discounted payments.
42 | */
43 | isIntro: boolean;
44 |
45 | /**
46 | * True, if the current phase represents the base plan. False otherwise.
47 | */
48 | isBasePlan: boolean;
49 |
50 | constructor(
51 | price: ProductPrice,
52 | billingPeriod: SubscriptionPeriod,
53 | billingCycleCount: number,
54 | recurrenceMode: PricingPhaseRecurrenceMode,
55 | type: PricingPhaseType,
56 | isTrial: boolean,
57 | isIntro: boolean,
58 | isBasePlan: boolean,
59 | ) {
60 | this.price = price;
61 | this.billingPeriod = billingPeriod;
62 | this.billingCycleCount = billingCycleCount;
63 | this.recurrenceMode = recurrenceMode;
64 | this.type = type;
65 | this.isTrial = isTrial;
66 | this.isIntro = isIntro;
67 | this.isBasePlan = isBasePlan;
68 | }
69 | }
70 |
71 | export default ProductPricingPhase;
72 |
--------------------------------------------------------------------------------
/src/dto/storeProducts/ProductStoreDetails.ts:
--------------------------------------------------------------------------------
1 | import {ProductType} from "../enums";
2 | import ProductOfferDetails from "./ProductOfferDetails";
3 | import ProductInAppDetails from "./ProductInAppDetails";
4 |
5 | /**
6 | * This class contains all the information about the concrete Google product,
7 | * either subscription or in-app. In case of a subscription also determines concrete base plan.
8 | */
9 | class ProductStoreDetails {
10 | /**
11 | * Identifier of the base plan to which these details relate.
12 | * Null for in-app products.
13 | */
14 | basePlanId: string | null;
15 |
16 | /**
17 | * Identifier of the subscription or the in-app product.
18 | */
19 | productId: string;
20 |
21 | /**
22 | * Name of the subscription or the in-app product.
23 | */
24 | name: string;
25 |
26 | /**
27 | * Title of the subscription or the in-app product.
28 | * The title includes the name of the app.
29 | */
30 | title: string;
31 |
32 | /**
33 | * Description of the subscription or the in-app product.
34 | */
35 | description: string;
36 |
37 | /**
38 | * Offer details for the subscription.
39 | * Offer details contain all the available variations of purchase offers,
40 | * including both base plan and eligible base plan + offer combinations
41 | * from Google Play Console for current {@link basePlanId}.
42 | * Null for in-app products.
43 | */
44 | subscriptionOfferDetails: ProductOfferDetails[] | null;
45 |
46 | /**
47 | * The most profitable subscription offer for the client in our opinion from all the available offers.
48 | * We calculate the cheapest price for the client by comparing all the trial or intro phases
49 | * and the base plan.
50 | */
51 | defaultSubscriptionOfferDetails: ProductOfferDetails | null;
52 |
53 | /**
54 | * Subscription offer details containing only the base plan without any offer.
55 | */
56 | basePlanSubscriptionOfferDetails: ProductOfferDetails | null;
57 |
58 | /**
59 | * Offer details for the in-app product.
60 | * Null for subscriptions.
61 | */
62 | inAppOfferDetails: ProductInAppDetails | null;
63 |
64 | /**
65 | * True, if there is any eligible offer with a trial
66 | * for this subscription and base plan combination.
67 | * False otherwise or for an in-app product.
68 | */
69 | hasTrialOffer: boolean;
70 |
71 | /**
72 | * True, if there is any eligible offer with an intro price
73 | * for this subscription and base plan combination.
74 | * False otherwise or for an in-app product.
75 | */
76 | hasIntroOffer: boolean;
77 |
78 | /**
79 | * True, if there is any eligible offer with a trial or an intro price
80 | * for this subscription and base plan combination.
81 | * False otherwise or for an in-app product.
82 | */
83 | hasTrialOrIntroOffer: boolean;
84 |
85 | /**
86 | * The calculated type of the current product.
87 | */
88 | productType: ProductType;
89 |
90 | /**
91 | * True, if the product type is InApp.
92 | */
93 | isInApp: boolean;
94 |
95 | /**
96 | * True, if the product type is Subscription.
97 | */
98 | isSubscription: boolean;
99 |
100 | /**
101 | * True, if the subscription product is prepaid, which means that users pay in advance -
102 | * they will need to make a new payment to extend their plan.
103 | */
104 | isPrepaid: boolean;
105 |
106 | /**
107 | * True, if the subscription product is installment, which means that users commit
108 | * to pay for a specified amount of periods every month.
109 | */
110 | isInstallment: boolean;
111 |
112 | constructor(
113 | basePlanId: string | null,
114 | productId: string,
115 | name: string,
116 | title: string,
117 | description: string,
118 | subscriptionOfferDetails: ProductOfferDetails[] | null,
119 | defaultSubscriptionOfferDetails: ProductOfferDetails | null,
120 | basePlanSubscriptionOfferDetails: ProductOfferDetails | null,
121 | inAppOfferDetails: ProductInAppDetails | null,
122 | hasTrialOffer: boolean,
123 | hasIntroOffer: boolean,
124 | hasTrialOrIntroOffer: boolean,
125 | productType: ProductType,
126 | isInApp: boolean,
127 | isSubscription: boolean,
128 | isPrepaid: boolean,
129 | isInstallment: boolean,
130 | ) {
131 | this.basePlanId = basePlanId;
132 | this.productId = productId;
133 | this.name = name;
134 | this.title = title;
135 | this.description = description;
136 | this.subscriptionOfferDetails = subscriptionOfferDetails;
137 | this.defaultSubscriptionOfferDetails = defaultSubscriptionOfferDetails;
138 | this.basePlanSubscriptionOfferDetails = basePlanSubscriptionOfferDetails;
139 | this.inAppOfferDetails = inAppOfferDetails;
140 | this.hasTrialOffer = hasTrialOffer;
141 | this.hasIntroOffer = hasIntroOffer;
142 | this.hasTrialOrIntroOffer = hasTrialOrIntroOffer;
143 | this.productType = productType;
144 | this.isInApp = isInApp;
145 | this.isSubscription = isSubscription;
146 | this.isPrepaid = isPrepaid;
147 | this.isInstallment = isInstallment;
148 | }
149 | }
150 |
151 | export default ProductStoreDetails;
152 |
--------------------------------------------------------------------------------
/src/dto/storeProducts/SKPaymentDiscount.ts:
--------------------------------------------------------------------------------
1 | class SKPaymentDiscount {
2 | identifier: string;
3 | keyIdentifier: string;
4 | nonce: string;
5 | signature: string;
6 | timestamp: number;
7 |
8 | constructor (
9 | identifier: string,
10 | keyIdentifier: string,
11 | nonce: string,
12 | signature: string,
13 | timestamp: number,
14 | ) {
15 | this.identifier = identifier;
16 | this.keyIdentifier = keyIdentifier;
17 | this.nonce = nonce;
18 | this.signature = signature;
19 | this.timestamp = timestamp;
20 | }
21 | }
22 |
23 | export default SKPaymentDiscount;
24 |
--------------------------------------------------------------------------------
/src/dto/storeProducts/SKProduct.ts:
--------------------------------------------------------------------------------
1 | import SKProductDiscount from "./SKProductDiscount";
2 | import SKSubscriptionPeriod from "./SKSubscriptionPeriod";
3 |
4 | class SKProduct {
5 | localizedDescription?: string;
6 | localizedTitle?: string;
7 | price: string;
8 | localeIdentifier?: string;
9 | productIdentifier?: string;
10 | isDownloadable: boolean;
11 | downloadContentVersion?: string;
12 | downloadContentLengths?: Array;
13 | subscriptionPeriod?: SKSubscriptionPeriod;
14 | productDiscount?: SKProductDiscount;
15 | discounts?: Array;
16 | subscriptionGroupIdentifier?: string;
17 | isFamilyShareable?: boolean;
18 | currencyCode: string;
19 |
20 | constructor(
21 | localizedDescription: string | undefined,
22 | localizedTitle: string | undefined,
23 | price: string,
24 | localeIdentifier: string | undefined,
25 | productIdentifier: string | undefined,
26 | isDownloadable: boolean,
27 | downloadContentVersion: string | undefined,
28 | downloadContentLengths: number[] | undefined,
29 | subscriptionPeriod: SKSubscriptionPeriod | undefined,
30 | productDiscount: SKProductDiscount | undefined,
31 | discounts: SKProductDiscount[] | undefined,
32 | subscriptionGroupIdentifier: string | undefined,
33 | isFamilyShareable: boolean | undefined,
34 | currencyCode: string
35 | ) {
36 | this.localizedDescription = localizedDescription;
37 | this.localizedTitle = localizedTitle;
38 | this.price = price;
39 | this.localeIdentifier = localeIdentifier;
40 | this.productIdentifier = productIdentifier;
41 | this.isDownloadable = isDownloadable;
42 | this.downloadContentVersion = downloadContentVersion;
43 | this.downloadContentLengths = downloadContentLengths;
44 | this.subscriptionPeriod = subscriptionPeriod;
45 | this.productDiscount = productDiscount;
46 | this.discounts = discounts;
47 | this.subscriptionGroupIdentifier = subscriptionGroupIdentifier;
48 | this.isFamilyShareable = isFamilyShareable;
49 | this.currencyCode = currencyCode;
50 | }
51 | }
52 |
53 | export default SKProduct;
54 |
--------------------------------------------------------------------------------
/src/dto/storeProducts/SKProductDiscount.ts:
--------------------------------------------------------------------------------
1 | import {
2 | SKProductDiscountPaymentModes,
3 | SKProductDiscountTypes,
4 | } from "../enums";
5 | import SKSubscriptionPeriod from "./SKSubscriptionPeriod";
6 |
7 | class SKProductDiscount {
8 | price: string;
9 | localeIdentifier?: string;
10 | numberOfPeriods: number;
11 | subscriptionPeriod?: SKSubscriptionPeriod;
12 | paymentMode: SKProductDiscountPaymentModes;
13 | identifier?: string;
14 | type: SKProductDiscountTypes;
15 | currencySymbol: string;
16 |
17 | constructor(
18 | price: string,
19 | localeIdentifier: string | undefined,
20 | numberOfPeriods: number,
21 | subscriptionPeriod: SKSubscriptionPeriod | undefined,
22 | paymentMode: SKProductDiscountPaymentModes,
23 | identifier: string | undefined,
24 | type: SKProductDiscountTypes,
25 | currencySymbol: string
26 | ) {
27 | this.price = price;
28 | this.localeIdentifier = localeIdentifier;
29 | this.numberOfPeriods = numberOfPeriods;
30 | this.subscriptionPeriod = subscriptionPeriod;
31 | this.paymentMode = paymentMode;
32 | this.identifier = identifier;
33 | this.type = type;
34 | this.currencySymbol = currencySymbol;
35 | }
36 | }
37 |
38 | export default SKProductDiscount;
39 |
--------------------------------------------------------------------------------
/src/dto/storeProducts/SKSubscriptionPeriod.ts:
--------------------------------------------------------------------------------
1 | import { SKPeriodUnits } from "../enums";
2 |
3 | class SKSubscriptionPeriod {
4 | numberOfUnits: number;
5 | unit: SKPeriodUnits;
6 |
7 | constructor(numberOfUnits: number, unit: SKPeriodUnits) {
8 | this.numberOfUnits = numberOfUnits;
9 | this.unit = unit;
10 | }
11 | }
12 |
13 | export default SKSubscriptionPeriod;
14 |
--------------------------------------------------------------------------------
/src/dto/storeProducts/SkuDetails.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @deprecated
3 | */
4 | class SkuDetails {
5 | description: string;
6 | freeTrialPeriod: string;
7 | iconUrl: string;
8 | introductoryPrice: string;
9 | introductoryPriceAmountMicros: number;
10 | introductoryPriceCycles: number;
11 | introductoryPricePeriod: string;
12 | originalJson: string;
13 | originalPrice: string;
14 | originalPriceAmountMicros: number;
15 | price: string;
16 | priceAmountMicros: number;
17 | priceCurrencyCode: string;
18 | sku: string;
19 | subscriptionPeriod: string;
20 | title: string;
21 | type: string;
22 | hashCode: number;
23 | toString: string;
24 |
25 | constructor(
26 | description: string,
27 | freeTrialPeriod: string,
28 | iconUrl: string,
29 | introductoryPrice: string,
30 | introductoryPriceAmountMicros: number,
31 | introductoryPriceCycles: number,
32 | introductoryPricePeriod: string,
33 | originalJson: string,
34 | originalPrice: string,
35 | originalPriceAmountMicros: number,
36 | price: string,
37 | priceAmountMicros: number,
38 | priceCurrencyCode: string,
39 | sku: string,
40 | subscriptionPeriod: string,
41 | title: string,
42 | type: string,
43 | hashCode: number,
44 | toString: string
45 | ) {
46 | this.description = description;
47 | this.freeTrialPeriod = freeTrialPeriod;
48 | this.iconUrl = iconUrl;
49 | this.introductoryPrice = introductoryPrice;
50 | this.introductoryPriceAmountMicros = introductoryPriceAmountMicros;
51 | this.introductoryPriceCycles = introductoryPriceCycles;
52 | this.introductoryPricePeriod = introductoryPricePeriod;
53 | this.originalJson = originalJson;
54 | this.originalPrice = originalPrice;
55 | this.originalPriceAmountMicros = originalPriceAmountMicros;
56 | this.price = price;
57 | this.priceAmountMicros = priceAmountMicros;
58 | this.priceCurrencyCode = priceCurrencyCode;
59 | this.sku = sku;
60 | this.subscriptionPeriod = subscriptionPeriod;
61 | this.title = title;
62 | this.type = type;
63 | this.hashCode = hashCode;
64 | this.toString = toString;
65 | }
66 | }
67 |
68 | export default SkuDetails;
69 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | export { default } from './Qonversion';
2 | export { default as QonversionApi } from './QonversionApi';
3 | export { default as QonversionConfig } from './QonversionConfig';
4 | export { default as QonversionConfigBuilder } from './QonversionConfigBuilder';
5 |
6 | export { default as Automations } from './Automations';
7 |
8 | export { default as ActionResult } from './dto/ActionResult';
9 | export { AutomationsDelegate } from './dto/AutomationsDelegate';
10 | export { default as AutomationsEvent } from './dto/AutomationsEvent';
11 | export { EntitlementsUpdateListener } from './dto/EntitlementsUpdateListener';
12 | export * from './dto/enums';
13 | export { default as IntroEligibility } from './dto/IntroEligibility';
14 | export { default as Offering } from './dto/Offering';
15 | export { default as Offerings } from './dto/Offerings';
16 | export { default as Entitlement } from './dto/Entitlement';
17 | export { default as Product } from './dto/Product';
18 | export { default as PurchaseModel } from './dto/PurchaseModel';
19 | export { default as PurchaseUpdateModel } from './dto/PurchaseUpdateModel';
20 | export { PromoPurchasesListener } from './dto/PromoPurchasesListener';
21 | export { default as RemoteConfig } from './dto/RemoteConfig';
22 | export { default as RemoteConfigList } from './dto/RemoteConfigList';
23 | export { ScreenPresentationConfig } from './dto/ScreenPresentationConfig';
24 | export { default as SubscriptionPeriod } from './dto/SubscriptionPeriod';
25 | export { default as QonversionError } from './dto/QonversionError';
26 | export { default as User } from './dto/User';
27 | export { default as UserProperty } from './dto/UserProperty';
28 | export { default as UserProperties } from './dto/UserProperties';
29 | export { default as ProductInAppDetails } from './dto/storeProducts/ProductInAppDetails';
30 | export { default as ProductInstallmentPlanDetails } from './dto/storeProducts/ProductInstallmentPlanDetails';
31 | export { default as ProductOfferDetails } from './dto/storeProducts/ProductOfferDetails';
32 | export { default as ProductPrice } from './dto/storeProducts/ProductPrice';
33 | export { default as ProductPricingPhase } from './dto/storeProducts/ProductPricingPhase';
34 | export { default as ProductStoreDetails } from './dto/storeProducts/ProductStoreDetails';
35 | export { default as SKProduct } from './dto/storeProducts/SKProduct';
36 | export { default as SKProductDiscount } from './dto/storeProducts/SKProductDiscount';
37 | export { default as SKSubscriptionPeriod } from './dto/storeProducts/SKSubscriptionPeriod';
38 | export { default as SkuDetails } from './dto/storeProducts/SkuDetails';
39 | export { default as PurchaseOptionsBuilder } from './dto/PurchaseOptionsBuilder';
40 | export { default as PurchaseOptions } from './dto/PurchaseOptionsBuilder';
41 |
--------------------------------------------------------------------------------
/src/internal/AutomationsInternal.ts:
--------------------------------------------------------------------------------
1 | import {AutomationsDelegate} from "../dto/AutomationsDelegate";
2 | import {NativeEventEmitter, NativeModules} from "react-native";
3 | import Mapper from "./Mapper";
4 | import AutomationsApi from '../AutomationsApi';
5 | import {ScreenPresentationConfig} from '../dto/ScreenPresentationConfig';
6 |
7 | const {RNAutomations} = NativeModules;
8 |
9 | const EVENT_SCREEN_SHOWN = "automations_screen_shown";
10 | const EVENT_ACTION_STARTED = "automations_action_started";
11 | const EVENT_ACTION_FAILED = "automations_action_failed";
12 | const EVENT_ACTION_FINISHED = "automations_action_finished";
13 | const EVENT_AUTOMATIONS_FINISHED = "automations_finished";
14 |
15 | export default class AutomationsInternal implements AutomationsApi {
16 |
17 | setDelegate(delegate: AutomationsDelegate) {
18 | AutomationsInternal.subscribe(delegate);
19 | }
20 |
21 | setNotificationsToken(token: string) {
22 | RNAutomations.setNotificationsToken(token);
23 | }
24 |
25 | async handleNotification(notificationData: Map): Promise {
26 | try {
27 | return await RNAutomations.handleNotification(notificationData);
28 | } catch (e) {
29 | return false;
30 | }
31 | }
32 |
33 | async getNotificationCustomPayload(notificationData: Map): Promise | null> {
34 | try {
35 | return await RNAutomations.getNotificationCustomPayload(notificationData) ?? null;
36 | } catch (e) {
37 | return null;
38 | }
39 | }
40 |
41 | async showScreen(screenId: string): Promise {
42 | return await RNAutomations.showScreen(screenId);
43 | }
44 |
45 | setScreenPresentationConfig(config: ScreenPresentationConfig, screenId?: string): void {
46 | const data = Mapper.convertScreenPresentationConfig(config);
47 | RNAutomations.setScreenPresentationConfig(data, screenId);
48 | }
49 |
50 | private static subscribe(automationsDelegate: AutomationsDelegate) {
51 | const eventEmitter = new NativeEventEmitter(RNAutomations);
52 |
53 | eventEmitter.removeAllListeners(EVENT_SCREEN_SHOWN);
54 | eventEmitter.addListener(EVENT_SCREEN_SHOWN, payload => {
55 | const screenId = payload["screenId"] ?? "";
56 | automationsDelegate.automationsDidShowScreen(screenId);
57 | });
58 |
59 | eventEmitter.removeAllListeners(EVENT_ACTION_STARTED);
60 | eventEmitter.addListener(EVENT_ACTION_STARTED, payload => {
61 | const actionResult = Mapper.convertActionResult(payload);
62 | automationsDelegate.automationsDidStartExecuting(actionResult);
63 | });
64 |
65 | eventEmitter.removeAllListeners(EVENT_ACTION_FAILED);
66 | eventEmitter.addListener(EVENT_ACTION_FAILED, payload => {
67 | const actionResult = Mapper.convertActionResult(payload);
68 | automationsDelegate.automationsDidFailExecuting(actionResult);
69 | });
70 |
71 | eventEmitter.removeAllListeners(EVENT_ACTION_FINISHED);
72 | eventEmitter.addListener(EVENT_ACTION_FINISHED, payload => {
73 | const actionResult = Mapper.convertActionResult(payload);
74 | automationsDelegate.automationsDidFinishExecuting(actionResult);
75 | });
76 |
77 | eventEmitter.removeAllListeners(EVENT_AUTOMATIONS_FINISHED);
78 | eventEmitter.addListener(EVENT_AUTOMATIONS_FINISHED, () => {
79 | automationsDelegate.automationsFinished();
80 | });
81 |
82 | RNAutomations.subscribe();
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/internal/utils.ts:
--------------------------------------------------------------------------------
1 | import {Platform} from "react-native";
2 |
3 | export const isIos = (): boolean => {
4 | return Platform.OS === "ios"
5 | };
6 |
7 | export const isAndroid = (): boolean => {
8 | return Platform.OS === "android"
9 | };
10 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "declaration": true,
4 | "module": "commonjs",
5 | "strict": true,
6 | "esModuleInterop": true,
7 | "emitDecoratorMetadata": true,
8 | "experimentalDecorators": true,
9 | "jsx": "react",
10 | "lib": ["es2017"],
11 | "target": "esnext",
12 | "rootDir": "./src",
13 | "outDir": "build",
14 | "sourceMap": true,
15 | "skipLibCheck": true
16 | },
17 | "exclude": ["node_modules"]
18 | }
--------------------------------------------------------------------------------
/yarn.lock:
--------------------------------------------------------------------------------
1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2 | # yarn lockfile v1
3 |
4 |
5 | "@types/prop-types@*":
6 | version "15.7.3"
7 | resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7"
8 | integrity sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==
9 |
10 | "@types/react-native@*":
11 | version "0.64.2"
12 | resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.64.2.tgz#2e344aeec0b4eb21fb9eaa0ed8973245c5601d56"
13 | integrity sha512-w2y04h+GVLY+OMlFSmq4adPuS51XtEp1yUr83OvXf+moMQ4zDG1Q07HhyvYDXdc+BSS9ANHySBqVCz0hFxli9Q==
14 | dependencies:
15 | "@types/react" "*"
16 |
17 | "@types/react@*":
18 | version "17.0.3"
19 | resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.3.tgz#ba6e215368501ac3826951eef2904574c262cc79"
20 | integrity sha512-wYOUxIgs2HZZ0ACNiIayItyluADNbONl7kt8lkLjVK8IitMH5QMyAh75Fwhmo37r1m7L2JaFj03sIfxBVDvRAg==
21 | dependencies:
22 | "@types/prop-types" "*"
23 | "@types/scheduler" "*"
24 | csstype "^3.0.2"
25 |
26 | "@types/scheduler@*":
27 | version "0.16.1"
28 | resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.1.tgz#18845205e86ff0038517aab7a18a62a6b9f71275"
29 | integrity sha512-EaCxbanVeyxDRTQBkdLb3Bvl/HK7PBK6UJjsSixB0iHKoWxE5uu2Q/DgtpOhPIojN0Zl1whvOd7PoHs2P0s5eA==
30 |
31 | csstype@^3.0.2:
32 | version "3.0.7"
33 | resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.0.7.tgz#2a5fb75e1015e84dd15692f71e89a1450290950b"
34 | integrity sha512-KxnUB0ZMlnUWCsx2Z8MUsr6qV6ja1w9ArPErJaJaF8a5SOWoHLIszeCTKGRGRgtLgYrs1E8CHkNSP1VZTTPc9g==
35 |
36 | typescript@^4.2.4:
37 | version "4.2.4"
38 | resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.2.4.tgz#8610b59747de028fda898a8aef0e103f156d0961"
39 | integrity sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==
40 |
--------------------------------------------------------------------------------