react-native-nami-sdk 3.3.0-beta.8 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc +4 -0
- package/README.md +9 -9
- package/android/README.md +3 -2
- package/android/build.gradle +27 -19
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/gradlew +0 -0
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/namiml/reactnative/Constants.kt +3 -0
- package/android/src/main/java/com/namiml/reactnative/NamiBridgeModule.kt +91 -0
- package/android/src/main/java/com/namiml/reactnative/NamiBridgePackage.java +140 -0
- package/android/src/main/java/com/{nami/reactlibrary → namiml/reactnative}/NamiCampaignManagerBridge.kt +24 -30
- package/android/src/main/java/com/{nami/reactlibrary → namiml/reactnative}/NamiCustomerManagerBridge.kt +14 -6
- package/android/src/main/java/com/{nami/reactlibrary/NamiEntitlementManagerBridgeModule.kt → namiml/reactnative/NamiEntitlementManagerBridge.kt} +18 -8
- package/android/src/main/java/com/namiml/reactnative/NamiFlowManagerBridge.kt +67 -0
- package/android/src/main/java/com/namiml/reactnative/NamiPaywallManagerBridgeModule.kt +196 -0
- package/android/src/main/java/com/namiml/reactnative/NamiPurchaseManagerBridge.kt +114 -0
- package/android/src/main/java/com/{nami/reactlibrary → namiml/reactnative}/NamiUtil.kt +26 -23
- package/{index.d.ts → dist/index.d.ts} +0 -2
- package/dist/specs/NativeNami.d.ts +15 -0
- package/dist/specs/NativeNamiCampaignManager.d.ts +82 -0
- package/dist/specs/NativeNamiCustomerManager.d.ts +29 -0
- package/dist/specs/NativeNamiEntitlementManager.d.ts +45 -0
- package/dist/specs/NativeNamiFlowManager.d.ts +8 -0
- package/dist/specs/NativeNamiPaywallManager.d.ts +71 -0
- package/dist/specs/NativeNamiPurchaseManager.d.ts +28 -0
- package/dist/src/Nami.d.ts +5 -0
- package/dist/src/NamiCampaignManager.d.ts +29 -0
- package/{src → dist/src}/NamiCustomerManager.d.ts +11 -13
- package/dist/src/NamiEntitlementManager.d.ts +13 -0
- package/dist/src/NamiFlowManager.d.ts +11 -0
- package/dist/src/NamiPaywallManager.d.ts +30 -0
- package/dist/src/NamiPurchaseManager.d.ts +17 -0
- package/dist/src/transformers.d.ts +3 -0
- package/{src → dist/src}/types.d.ts +35 -6
- package/dist/src/version.d.ts +5 -0
- package/index.ts +0 -2
- package/ios/Nami.m +8 -88
- package/ios/Nami.swift +85 -0
- package/ios/NamiCampaignManagerBridge.m +3 -3
- package/ios/NamiCampaignManagerBridge.swift +49 -61
- package/ios/NamiCustomerManager.m +2 -2
- package/ios/NamiCustomerManager.swift +13 -3
- package/ios/NamiEntitlementManagerBridge.m +2 -3
- package/ios/NamiEntitlementManagerBridge.swift +48 -39
- package/ios/NamiFlowManagerBridge.m +2 -2
- package/ios/NamiFlowManagerBridge.swift +10 -6
- package/ios/NamiPaywallManagerBridge.m +3 -3
- package/ios/NamiPaywallManagerBridge.swift +16 -6
- package/ios/NamiPurchaseManagerBridge.m +3 -2
- package/ios/NamiPurchaseManagerBridge.swift +15 -10
- package/ios/RNNami-Bridging-Header.h +1 -3
- package/package.json +20 -8
- package/react-native-config.js +9 -0
- package/react-native-nami-sdk.podspec +11 -3
- package/scripts/generate-version.ts +18 -0
- package/specs/NativeNami.ts +16 -0
- package/specs/NativeNamiCampaignManager.ts +94 -0
- package/specs/NativeNamiCustomerManager.ts +37 -0
- package/specs/NativeNamiEntitlementManager.ts +54 -0
- package/specs/NativeNamiFlowManager.ts +12 -0
- package/specs/NativeNamiPaywallManager.ts +85 -0
- package/specs/NativeNamiPurchaseManager.ts +33 -0
- package/src/Nami.ts +28 -18
- package/src/NamiCampaignManager.ts +57 -53
- package/src/NamiCustomerManager.ts +55 -81
- package/src/NamiEntitlementManager.ts +49 -36
- package/src/NamiFlowManager.ts +35 -45
- package/src/NamiPaywallManager.ts +84 -139
- package/src/NamiPurchaseManager.ts +69 -70
- package/src/transformers.ts +21 -0
- package/src/types.ts +39 -7
- package/src/version.ts +5 -0
- package/tsconfig.json +24 -22
- package/.eslintignore +0 -3
- package/.eslintrc.js +0 -52
- package/.github/workflows/CI.yaml +0 -341
- package/.github/workflows/app_prod.yaml +0 -387
- package/.github/workflows/app_stg.yaml +0 -398
- package/.github/workflows/build.yml +0 -70
- package/.pre-commit-config.yaml +0 -24
- package/.prettierrc.js +0 -7
- package/android/src/main/java/com/nami/reactlibrary/Constants.kt +0 -3
- package/android/src/main/java/com/nami/reactlibrary/NamiBridgeModule.kt +0 -141
- package/android/src/main/java/com/nami/reactlibrary/NamiBridgePackage.java +0 -51
- package/android/src/main/java/com/nami/reactlibrary/NamiFlowManagerBridge.kt +0 -60
- package/android/src/main/java/com/nami/reactlibrary/NamiMLManagerBridgeModule.kt +0 -58
- package/android/src/main/java/com/nami/reactlibrary/NamiManagerBridge.kt +0 -26
- package/android/src/main/java/com/nami/reactlibrary/NamiPaywallManagerBridgeModule.kt +0 -258
- package/android/src/main/java/com/nami/reactlibrary/NamiPurchaseManagerBridge.kt +0 -108
- package/build-utils/get_version_code.py +0 -140
- package/build-utils/preflight.py +0 -46
- package/ios/NamiMLManagerBridge.m +0 -93
- package/ios/NamiManager.m +0 -18
- package/ios/NamiManager.swift +0 -30
- package/ios/RNNami.h +0 -10
- package/ios/RNNami.m +0 -13
- package/src/Nami.d.ts +0 -8
- package/src/NamiCampaignManager.d.ts +0 -18
- package/src/NamiEntitlementManager.d.ts +0 -15
- package/src/NamiFlowManager.d.ts +0 -32
- package/src/NamiMLManager.d.ts +0 -7
- package/src/NamiMLManager.ts +0 -13
- package/src/NamiManager.d.ts +0 -5
- package/src/NamiManager.ts +0 -14
- package/src/NamiPaywallManager.d.ts +0 -34
- package/src/NamiPurchaseManager.d.ts +0 -20
package/.prettierrc
ADDED
package/README.md
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
# React Native Bridge for the Nami SDK
|
|
4
4
|
|
|
5
|
-
Nami ML gives you everything you need to power your paywall, streamline subscription management, and drive revenue growth through instantly deployable paywalls, precise targeting and segmentation, and enterprise-grade security and
|
|
5
|
+
Nami ML gives you everything you need to power your paywall, streamline subscription management, and drive revenue growth through instantly deployable paywalls, precise targeting and segmentation, and enterprise-grade security and scalability.
|
|
6
6
|
|
|
7
7
|
Go beyond basic IAP and focus on results with:
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
- Library of smart paywall templates to choose from, implemented natively
|
|
10
|
+
- No-code paywall creator so you can launch a new paywall design instantly, without submitting an app update
|
|
11
|
+
- Experimentation engine to run paywall A/B tests so you can improve your conversion rates
|
|
12
|
+
- Built-in IAP & subscription management and analytics, so you don't need another solution
|
|
13
13
|
|
|
14
14
|
Nami is simple adopt while giving you the tools you need to improve revenue. Our free tier is generous, and gives you everything you need to get started. [Sign up for a free account](https://app.namiml.com/join/)
|
|
15
15
|
|
|
@@ -20,18 +20,18 @@ Get started by heading over to our [quick start guide](https://learn.namiml.com/
|
|
|
20
20
|
### Build the Bridge Locally
|
|
21
21
|
|
|
22
22
|
```
|
|
23
|
-
|
|
23
|
+
npm run prepare && npm pack
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
This will generate a file `react-native-nami-sdk-vx.x.x.tgz` with the current version number of the bridge.
|
|
26
|
+
This will generate a file `react-native-nami-sdk-vx.x.x.tgz` with the current version number of the bridge. You can add this to a project by
|
|
27
27
|
|
|
28
28
|
```
|
|
29
|
-
|
|
29
|
+
npm install react-native-nami-sdk-vx.x.x.tgz
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
### Installing from NPM
|
|
33
33
|
|
|
34
|
-
The bridge is also available as a package on NPM.
|
|
34
|
+
The bridge is also available as a package on NPM. You can install it via yarn or npm
|
|
35
35
|
|
|
36
36
|
```
|
|
37
37
|
npm install react-native-nami-sdk --save
|
package/android/README.md
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
README
|
|
2
|
-
======
|
|
1
|
+
# README
|
|
3
2
|
|
|
4
3
|
If you want to publish the lib as a maven dependency, follow these steps before publishing a new version to npm:
|
|
5
4
|
|
|
6
5
|
1. Be sure to have the Android [SDK](https://developer.android.com/studio/index.html) and [NDK](https://developer.android.com/ndk/guides/index.html) installed
|
|
7
6
|
2. Be sure to have a `local.properties` file in this folder that points to the Android SDK and NDK
|
|
7
|
+
|
|
8
8
|
```
|
|
9
9
|
ndk.dir=/Users/{username}/Library/Android/sdk/ndk-bundle
|
|
10
10
|
sdk.dir=/Users/{username}/Library/Android/sdk
|
|
11
11
|
```
|
|
12
|
+
|
|
12
13
|
3. Delete the `maven` folder
|
|
13
14
|
4. Run `./gradlew installArchives`
|
|
14
15
|
5. Verify that latest set of generated files is in the maven folder with the correct version number
|
package/android/build.gradle
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
// based on:
|
|
3
|
-
//
|
|
4
|
-
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle
|
|
5
|
-
// original location:
|
|
6
|
-
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle
|
|
7
|
-
//
|
|
8
|
-
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle
|
|
9
|
-
// original location:
|
|
10
|
-
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
|
|
11
|
-
def DEFAULT_BUILD_TOOLS_VERSION = '34.0.0'
|
|
1
|
+
def DEFAULT_BUILD_TOOLS_VERSION = '35.0.0'
|
|
12
2
|
def safeExtGet(prop, fallback) {
|
|
13
3
|
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
14
4
|
}
|
|
5
|
+
|
|
6
|
+
def isNewArchitectureEnabled() {
|
|
7
|
+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (isNewArchitectureEnabled()) {
|
|
11
|
+
apply plugin: 'com.facebook.react'
|
|
12
|
+
}
|
|
13
|
+
|
|
15
14
|
apply plugin: 'com.android.library'
|
|
16
15
|
// apply plugin: 'maven'
|
|
17
16
|
apply plugin: "kotlin-android"
|
|
18
17
|
buildscript {
|
|
19
|
-
ext.kotlin_version = '1.
|
|
18
|
+
ext.kotlin_version = '1.9.20'
|
|
20
19
|
// The Android Gradle plugin is only required when opening the android folder stand-alone.
|
|
21
20
|
// This avoids unnecessary downloads and potential conflicts when the library is included as a
|
|
22
21
|
// module dependency in an application project.
|
|
@@ -27,19 +26,20 @@ buildscript {
|
|
|
27
26
|
google()
|
|
28
27
|
}
|
|
29
28
|
dependencies {
|
|
30
|
-
classpath 'com.android.tools.build:gradle:
|
|
29
|
+
classpath 'com.android.tools.build:gradle:8.6.1'
|
|
31
30
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
34
|
android {
|
|
36
|
-
compileSdkVersion
|
|
35
|
+
compileSdkVersion 35
|
|
37
36
|
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
|
|
38
37
|
defaultConfig {
|
|
39
|
-
minSdkVersion
|
|
40
|
-
targetSdkVersion
|
|
38
|
+
minSdkVersion 23
|
|
39
|
+
targetSdkVersion 35
|
|
41
40
|
versionCode 1
|
|
42
41
|
versionName "1.0"
|
|
42
|
+
buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
|
|
43
43
|
}
|
|
44
44
|
compileOptions {
|
|
45
45
|
coreLibraryDesugaringEnabled true
|
|
@@ -85,12 +85,20 @@ dependencies {
|
|
|
85
85
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
86
86
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
|
87
87
|
|
|
88
|
-
playImplementation "com.namiml:sdk-android:3.3.0
|
|
89
|
-
amazonImplementation "com.namiml:sdk-amazon:3.3.0
|
|
88
|
+
playImplementation "com.namiml:sdk-android:3.3.0"
|
|
89
|
+
amazonImplementation "com.namiml:sdk-amazon:3.3.0"
|
|
90
90
|
|
|
91
91
|
implementation "com.facebook.react:react-native:+" // From node_modules
|
|
92
|
-
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:
|
|
92
|
+
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.0.4"
|
|
93
|
+
|
|
94
|
+
}
|
|
93
95
|
|
|
96
|
+
if (isNewArchitectureEnabled()) {
|
|
97
|
+
react {
|
|
98
|
+
jsRootDir = file("../src/")
|
|
99
|
+
libraryName = "Nami"
|
|
100
|
+
codegenJavaPackageName = "com.namiml.reactnative"
|
|
101
|
+
}
|
|
94
102
|
}
|
|
95
103
|
|
|
96
104
|
configurations {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#Wed May 26 17:12:26 EDT 2021
|
|
2
2
|
distributionBase=GRADLE_USER_HOME
|
|
3
|
-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.
|
|
3
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
|
4
4
|
distributionPath=wrapper/dists
|
|
5
5
|
zipStorePath=wrapper/dists
|
|
6
6
|
zipStoreBase=GRADLE_USER_HOME
|
package/android/gradlew
CHANGED
|
File without changes
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
package com.namiml.reactnative
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.*
|
|
4
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
5
|
+
import com.facebook.react.turbomodule.core.interfaces.TurboModule
|
|
6
|
+
import com.namiml.Nami
|
|
7
|
+
import com.namiml.NamiConfiguration
|
|
8
|
+
import com.namiml.NamiLanguageCode
|
|
9
|
+
import com.namiml.NamiLogLevel
|
|
10
|
+
import android.util.Log
|
|
11
|
+
|
|
12
|
+
@ReactModule(name = NamiBridgeModule.NAME)
|
|
13
|
+
class NamiBridgeModule internal constructor(
|
|
14
|
+
private val context: ReactApplicationContext
|
|
15
|
+
) : ReactContextBaseJavaModule(context), TurboModule {
|
|
16
|
+
|
|
17
|
+
companion object {
|
|
18
|
+
const val NAME = "RNNami"
|
|
19
|
+
|
|
20
|
+
private const val CONFIG_MAP_PLATFORM_ID_KEY = "appPlatformID"
|
|
21
|
+
private const val CONFIG_MAP_LOG_LEVEL_KEY = "logLevel"
|
|
22
|
+
private const val CONFIG_MAP_DEVELOPMENT_MODE_KEY = "developmentMode"
|
|
23
|
+
private const val CONFIG_MAP_NAMI_COMMANDS_KEY = "namiCommands"
|
|
24
|
+
private const val CONFIG_MAP_LANGUAGE_CODE_KEY = "namiLanguageCode"
|
|
25
|
+
private const val CONFIG_MAP_INITIAL_CONFIG_KEY = "initialConfig"
|
|
26
|
+
|
|
27
|
+
private const val PLATFORM_ID_ERROR_VALUE = "APPPLATFORMID_NOT_FOUND"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
override fun getName(): String = NAME
|
|
31
|
+
|
|
32
|
+
@ReactMethod
|
|
33
|
+
fun sdkConfigured(promise: Promise) {
|
|
34
|
+
promise.resolve(Nami.isInitialized())
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@ReactMethod
|
|
38
|
+
fun configure(configDict: ReadableMap, promise: Promise) {
|
|
39
|
+
logNewArchitectureStatus()
|
|
40
|
+
|
|
41
|
+
val appPlatformID = configDict.getString(CONFIG_MAP_PLATFORM_ID_KEY) ?: PLATFORM_ID_ERROR_VALUE
|
|
42
|
+
val builder = NamiConfiguration.Builder(context.applicationContext, appPlatformID)
|
|
43
|
+
|
|
44
|
+
when (configDict.getString(CONFIG_MAP_LOG_LEVEL_KEY)) {
|
|
45
|
+
"INFO" -> builder.logLevel(NamiLogLevel.INFO)
|
|
46
|
+
"WARN" -> builder.logLevel(NamiLogLevel.WARN)
|
|
47
|
+
"ERROR" -> builder.logLevel(NamiLogLevel.ERROR)
|
|
48
|
+
else -> builder.logLevel(NamiLogLevel.DEBUG)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (configDict.hasKey(CONFIG_MAP_DEVELOPMENT_MODE_KEY) &&
|
|
52
|
+
configDict.getBoolean(CONFIG_MAP_DEVELOPMENT_MODE_KEY)) {
|
|
53
|
+
builder.developmentMode = true
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
configDict.getString(CONFIG_MAP_LANGUAGE_CODE_KEY)?.let { code ->
|
|
57
|
+
NamiLanguageCode.values().find { it.code == code }?.let {
|
|
58
|
+
builder.namiLanguageCode = it
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
configDict.getArray(CONFIG_MAP_NAMI_COMMANDS_KEY)?.let { commandsArray ->
|
|
63
|
+
val settingsList = mutableListOf<String>()
|
|
64
|
+
for (i in 0 until commandsArray.size()) {
|
|
65
|
+
commandsArray.getString(i)?.let { settingsList.add(it) }
|
|
66
|
+
}
|
|
67
|
+
builder.settingsList = settingsList
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
configDict.getString(CONFIG_MAP_INITIAL_CONFIG_KEY)?.let {
|
|
71
|
+
builder.initialConfig = it
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
context.runOnUiQueueThread {
|
|
75
|
+
Nami.configure(builder.build()) { result ->
|
|
76
|
+
val resultMap = Arguments.createMap().apply {
|
|
77
|
+
putBoolean("success", result)
|
|
78
|
+
}
|
|
79
|
+
promise.resolve(resultMap)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
fun logNewArchitectureStatus() {
|
|
85
|
+
val isNewArch = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
86
|
+
Log.d("RNNami", "New Architecture is ${if (isNewArch) "ENABLED" else "DISABLED"}")
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@ReactMethod fun addListener(eventName: String?) {}
|
|
90
|
+
@ReactMethod fun removeListeners(count: Int?) {}
|
|
91
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
package com.namiml.reactnative;
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.TurboReactPackage;
|
|
4
|
+
import com.facebook.react.bridge.NativeModule;
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfo;
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider;
|
|
8
|
+
import com.facebook.react.uimanager.ViewManager;
|
|
9
|
+
import com.namiml.reactnative.BuildConfig;
|
|
10
|
+
|
|
11
|
+
import java.util.Collections;
|
|
12
|
+
import java.util.HashMap;
|
|
13
|
+
import java.util.List;
|
|
14
|
+
import java.util.Map;
|
|
15
|
+
|
|
16
|
+
public class NamiBridgePackage extends TurboReactPackage {
|
|
17
|
+
|
|
18
|
+
@Override
|
|
19
|
+
public NativeModule getModule(String name, ReactApplicationContext context) {
|
|
20
|
+
return switch (name) {
|
|
21
|
+
case NamiBridgeModule.NAME -> new NamiBridgeModule(context);
|
|
22
|
+
case NamiCampaignManagerBridgeModule.NAME ->
|
|
23
|
+
new NamiCampaignManagerBridgeModule(context);
|
|
24
|
+
case NamiEntitlementManagerBridgeModule.NAME ->
|
|
25
|
+
new NamiEntitlementManagerBridgeModule(context);
|
|
26
|
+
case NamiCustomerManagerBridgeModule.NAME ->
|
|
27
|
+
new NamiCustomerManagerBridgeModule(context);
|
|
28
|
+
case NamiFlowManagerBridgeModule.NAME -> new NamiFlowManagerBridgeModule(context);
|
|
29
|
+
case NamiPaywallManagerBridgeModule.NAME -> new NamiPaywallManagerBridgeModule(context);
|
|
30
|
+
case NamiPurchaseManagerBridgeModule.NAME ->
|
|
31
|
+
new NamiPurchaseManagerBridgeModule(context);
|
|
32
|
+
default -> null;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@Override
|
|
37
|
+
public ReactModuleInfoProvider getReactModuleInfoProvider() {
|
|
38
|
+
return () -> {
|
|
39
|
+
final Map<String, ReactModuleInfo> moduleInfos = new HashMap<>();
|
|
40
|
+
|
|
41
|
+
// Declare all TurboModules here
|
|
42
|
+
moduleInfos.put(
|
|
43
|
+
NamiBridgeModule.NAME,
|
|
44
|
+
new ReactModuleInfo(
|
|
45
|
+
NamiBridgeModule.NAME,
|
|
46
|
+
NamiBridgeModule.NAME,
|
|
47
|
+
false,
|
|
48
|
+
false,
|
|
49
|
+
true,
|
|
50
|
+
false,
|
|
51
|
+
BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
52
|
+
)
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
moduleInfos.put(
|
|
56
|
+
NamiCampaignManagerBridgeModule.NAME,
|
|
57
|
+
new ReactModuleInfo(
|
|
58
|
+
NamiCampaignManagerBridgeModule.NAME,
|
|
59
|
+
NamiCampaignManagerBridgeModule.NAME,
|
|
60
|
+
false,
|
|
61
|
+
false,
|
|
62
|
+
true,
|
|
63
|
+
false,
|
|
64
|
+
BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
65
|
+
)
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
moduleInfos.put(
|
|
69
|
+
NamiEntitlementManagerBridgeModule.NAME,
|
|
70
|
+
new ReactModuleInfo(
|
|
71
|
+
NamiEntitlementManagerBridgeModule.NAME,
|
|
72
|
+
NamiEntitlementManagerBridgeModule.NAME,
|
|
73
|
+
false,
|
|
74
|
+
false,
|
|
75
|
+
true,
|
|
76
|
+
false,
|
|
77
|
+
BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
78
|
+
)
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
moduleInfos.put(
|
|
82
|
+
NamiCustomerManagerBridgeModule.NAME,
|
|
83
|
+
new ReactModuleInfo(
|
|
84
|
+
NamiCustomerManagerBridgeModule.NAME,
|
|
85
|
+
NamiCustomerManagerBridgeModule.NAME,
|
|
86
|
+
false,
|
|
87
|
+
false,
|
|
88
|
+
true,
|
|
89
|
+
false,
|
|
90
|
+
BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
91
|
+
)
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
moduleInfos.put(
|
|
95
|
+
NamiFlowManagerBridgeModule.NAME,
|
|
96
|
+
new ReactModuleInfo(
|
|
97
|
+
NamiFlowManagerBridgeModule.NAME,
|
|
98
|
+
NamiFlowManagerBridgeModule.NAME,
|
|
99
|
+
false,
|
|
100
|
+
false,
|
|
101
|
+
true,
|
|
102
|
+
false,
|
|
103
|
+
BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
104
|
+
)
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
moduleInfos.put(
|
|
108
|
+
NamiPaywallManagerBridgeModule.NAME,
|
|
109
|
+
new ReactModuleInfo(
|
|
110
|
+
NamiPaywallManagerBridgeModule.NAME,
|
|
111
|
+
NamiPaywallManagerBridgeModule.NAME,
|
|
112
|
+
false,
|
|
113
|
+
false,
|
|
114
|
+
true,
|
|
115
|
+
false,
|
|
116
|
+
BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
117
|
+
)
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
moduleInfos.put(
|
|
121
|
+
NamiPurchaseManagerBridgeModule.NAME,
|
|
122
|
+
new ReactModuleInfo(
|
|
123
|
+
NamiPurchaseManagerBridgeModule.NAME,
|
|
124
|
+
NamiPurchaseManagerBridgeModule.NAME,
|
|
125
|
+
false,
|
|
126
|
+
false,
|
|
127
|
+
true,
|
|
128
|
+
false,
|
|
129
|
+
BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
130
|
+
)
|
|
131
|
+
);
|
|
132
|
+
return moduleInfos;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@Override
|
|
137
|
+
public List<ViewManager> createViewManagers(ReactApplicationContext context) {
|
|
138
|
+
return Collections.emptyList();
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -1,22 +1,27 @@
|
|
|
1
|
-
package com.
|
|
1
|
+
package com.namiml.reactnative
|
|
2
2
|
|
|
3
3
|
import android.app.Activity
|
|
4
|
-
import android.content.Intent
|
|
5
4
|
import android.net.Uri
|
|
6
5
|
import android.util.Log
|
|
7
6
|
import com.facebook.react.bridge.*
|
|
7
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
8
8
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
9
|
+
import com.facebook.react.turbomodule.core.interfaces.TurboModule
|
|
9
10
|
import com.namiml.billing.NamiPurchase
|
|
10
11
|
import com.namiml.campaign.LaunchCampaignResult
|
|
11
12
|
import com.namiml.campaign.NamiCampaign
|
|
12
13
|
import com.namiml.campaign.NamiCampaignManager
|
|
13
14
|
import com.namiml.paywall.model.NamiPaywallEvent
|
|
14
15
|
import com.namiml.paywall.model.PaywallLaunchContext
|
|
16
|
+
import androidx.core.net.toUri
|
|
17
|
+
|
|
18
|
+
@ReactModule(name = NamiCampaignManagerBridgeModule.NAME)
|
|
19
|
+
class NamiCampaignManagerBridgeModule internal constructor(
|
|
20
|
+
private val reactContext: ReactApplicationContext
|
|
21
|
+
) : ReactContextBaseJavaModule(reactContext), TurboModule {
|
|
15
22
|
|
|
16
|
-
class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
17
|
-
ReactContextBaseJavaModule(reactContext), ActivityEventListener {
|
|
18
|
-
// handlePaywallCallback metadata
|
|
19
23
|
companion object {
|
|
24
|
+
const val NAME = "RNNamiCampaignManager"
|
|
20
25
|
const val CAMPAIGN_ID = "campaignId"
|
|
21
26
|
const val CAMPAIGN_LABEL = "campaignLabel"
|
|
22
27
|
const val PAYWALL_ID = "paywallId"
|
|
@@ -34,11 +39,12 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
34
39
|
const val DEEP_LINK_URL = "deeplinkUrl"
|
|
35
40
|
const val TIME_SPENT_ON_PAYWALL = "timeSpentOnPaywall"
|
|
36
41
|
const val VIDEO_METADATA = "videoMetadata"
|
|
37
|
-
const val
|
|
42
|
+
const val NAMI_PAYWALL_EVENT = "NamiPaywallEvent"
|
|
38
43
|
}
|
|
39
44
|
|
|
45
|
+
|
|
40
46
|
override fun getName(): String {
|
|
41
|
-
return
|
|
47
|
+
return NAME
|
|
42
48
|
}
|
|
43
49
|
|
|
44
50
|
private fun campaignToReadableMap(campaign: NamiCampaign): ReadableMap {
|
|
@@ -60,7 +66,7 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
60
66
|
) {
|
|
61
67
|
var theActivity: Activity? = null
|
|
62
68
|
if (reactApplicationContext.hasCurrentActivity()) {
|
|
63
|
-
theActivity = reactApplicationContext.
|
|
69
|
+
theActivity = reactApplicationContext.currentActivity
|
|
64
70
|
}
|
|
65
71
|
|
|
66
72
|
var paywallLaunchContext: PaywallLaunchContext? = null
|
|
@@ -79,7 +85,7 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
79
85
|
}
|
|
80
86
|
}
|
|
81
87
|
}
|
|
82
|
-
Log.d(
|
|
88
|
+
Log.d(NAME, "productGroups $productGroups")
|
|
83
89
|
}
|
|
84
90
|
|
|
85
91
|
if (context.hasKey("customAttributes")) {
|
|
@@ -90,7 +96,7 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
90
96
|
val key = keyIterator.nextKey()
|
|
91
97
|
customAttributes[key] = attr.getString(key) ?: ""
|
|
92
98
|
}
|
|
93
|
-
Log.d(
|
|
99
|
+
Log.d(NAME, "customAttributes $customAttributes")
|
|
94
100
|
}
|
|
95
101
|
}
|
|
96
102
|
|
|
@@ -100,7 +106,7 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
100
106
|
try {
|
|
101
107
|
customObject = attr.toHashMap().toMutableMap()
|
|
102
108
|
} catch (e: Exception) {
|
|
103
|
-
Log.d(
|
|
109
|
+
Log.d(NAME, "Unable to parse PaywallLaunchContext customObject $customObject")
|
|
104
110
|
}
|
|
105
111
|
}
|
|
106
112
|
}
|
|
@@ -122,7 +128,7 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
122
128
|
)
|
|
123
129
|
}
|
|
124
130
|
|
|
125
|
-
val uriObject: Uri? = if (withUrl != null)
|
|
131
|
+
val uriObject: Uri? = if (withUrl != null) withUrl.toUri() else null
|
|
126
132
|
|
|
127
133
|
if (label != null) {
|
|
128
134
|
NamiCampaignManager.launch(
|
|
@@ -214,7 +220,7 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
214
220
|
resultMap.putDouble(TIME_SPENT_ON_PAYWALL, paywallEvent.timeSpentOnPaywall ?: 0.0)
|
|
215
221
|
}
|
|
216
222
|
|
|
217
|
-
emitEvent(
|
|
223
|
+
emitEvent(NAMI_PAYWALL_EVENT, resultMap)
|
|
218
224
|
}
|
|
219
225
|
|
|
220
226
|
private fun createPurchaseArray(purchases: List<NamiPurchase>?): WritableArray {
|
|
@@ -223,7 +229,7 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
223
229
|
try {
|
|
224
230
|
pushMap(purchase.toPurchaseDict())
|
|
225
231
|
} catch (e: Exception) {
|
|
226
|
-
Log.e(
|
|
232
|
+
Log.e(NAME, "Error while converting data in createPurchaseArray to a Map", e)
|
|
227
233
|
}
|
|
228
234
|
}
|
|
229
235
|
}
|
|
@@ -237,7 +243,7 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
237
243
|
if (emitter is DeviceEventManagerModule.RCTDeviceEventEmitter) {
|
|
238
244
|
emitter.emit(event, map)
|
|
239
245
|
} else {
|
|
240
|
-
Log.w(
|
|
246
|
+
Log.w(NAME, "Cannot emit $event event: RCTDeviceEventEmitter instance is null")
|
|
241
247
|
}
|
|
242
248
|
}
|
|
243
249
|
|
|
@@ -256,19 +262,6 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
256
262
|
}
|
|
257
263
|
}
|
|
258
264
|
|
|
259
|
-
override fun onActivityResult(
|
|
260
|
-
activity: Activity?,
|
|
261
|
-
requestCode: Int,
|
|
262
|
-
resultCode: Int,
|
|
263
|
-
intent: Intent?,
|
|
264
|
-
) {
|
|
265
|
-
Log.d(LOG_TAG, "Nami Activity result listener activated, code is $requestCode")
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
override fun onNewIntent(intent: Intent?) {
|
|
269
|
-
// do nothing
|
|
270
|
-
}
|
|
271
|
-
|
|
272
265
|
@ReactMethod
|
|
273
266
|
fun allCampaigns(promise: Promise) {
|
|
274
267
|
val campaigns = NamiCampaignManager.allCampaigns()
|
|
@@ -287,14 +280,15 @@ class NamiCampaignManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
287
280
|
val isCampaignAvailable =
|
|
288
281
|
when {
|
|
289
282
|
campaignSource == null -> NamiCampaignManager.isCampaignAvailable()
|
|
290
|
-
|
|
283
|
+
campaignSource.toUri().scheme != null -> NamiCampaignManager.isCampaignAvailable(
|
|
284
|
+
campaignSource.toUri())
|
|
291
285
|
else -> NamiCampaignManager.isCampaignAvailable(campaignSource)
|
|
292
286
|
}
|
|
293
287
|
promise.resolve(isCampaignAvailable)
|
|
294
288
|
}
|
|
295
289
|
|
|
296
290
|
@ReactMethod
|
|
297
|
-
|
|
291
|
+
fun refresh(promise: Promise) {
|
|
298
292
|
NamiCampaignManager.refresh { campaigns ->
|
|
299
293
|
val array = WritableNativeArray()
|
|
300
294
|
campaigns?.forEach { campaign ->
|
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
package com.
|
|
1
|
+
package com.namiml.reactnative
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.*
|
|
4
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
4
5
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
6
|
+
import com.facebook.react.turbomodule.core.interfaces.TurboModule
|
|
5
7
|
import com.namiml.customer.CustomerJourneyState
|
|
6
8
|
import com.namiml.customer.NamiCustomerManager
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
@ReactModule(name = NamiCustomerManagerBridgeModule.NAME)
|
|
11
|
+
class NamiCustomerManagerBridgeModule internal constructor(
|
|
12
|
+
private val reactContext: ReactApplicationContext
|
|
13
|
+
) : ReactContextBaseJavaModule(reactContext), TurboModule {
|
|
14
|
+
|
|
15
|
+
companion object {
|
|
16
|
+
const val NAME = "RNNamiCustomerManager"
|
|
17
|
+
}
|
|
10
18
|
|
|
11
19
|
override fun getName(): String {
|
|
12
|
-
return
|
|
20
|
+
return NAME
|
|
13
21
|
}
|
|
14
22
|
|
|
15
23
|
private fun journeyStateToReadableMap(journeyState: CustomerJourneyState): ReadableMap {
|
|
@@ -109,7 +117,7 @@ class NamiCustomerManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
109
117
|
fun registerJourneyStateHandler() {
|
|
110
118
|
NamiCustomerManager.registerJourneyStateHandler { journeyState ->
|
|
111
119
|
val handledJourneyState = journeyStateToReadableMap(journeyState)
|
|
112
|
-
|
|
120
|
+
reactContext
|
|
113
121
|
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
114
122
|
.emit("JourneyStateChanged", handledJourneyState)
|
|
115
123
|
}
|
|
@@ -122,7 +130,7 @@ class NamiCustomerManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
|
122
130
|
body.putString("action", action.toString())
|
|
123
131
|
body.putBoolean("success", success)
|
|
124
132
|
body.putString("error", error.toString())
|
|
125
|
-
|
|
133
|
+
reactContext
|
|
126
134
|
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
127
135
|
.emit("AccountStateChanged", body)
|
|
128
136
|
}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
package com.
|
|
1
|
+
package com.namiml.reactnative
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.*
|
|
4
4
|
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
5
5
|
import com.namiml.entitlement.NamiEntitlementManager
|
|
6
|
-
|
|
7
|
-
import com.facebook.react.
|
|
6
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
7
|
+
import com.facebook.react.turbomodule.core.interfaces.TurboModule
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
@ReactModule(name = NamiEntitlementManagerBridgeModule.NAME)
|
|
10
|
+
class NamiEntitlementManagerBridgeModule internal constructor(
|
|
11
|
+
reactContext: ReactApplicationContext
|
|
12
|
+
) : ReactContextBaseJavaModule(reactContext), TurboModule {
|
|
13
|
+
|
|
14
|
+
companion object {
|
|
15
|
+
const val NAME = "RNNamiEntitlementManager"
|
|
16
|
+
}
|
|
11
17
|
|
|
12
18
|
override fun getName(): String {
|
|
13
|
-
return
|
|
19
|
+
return NAME
|
|
14
20
|
}
|
|
15
21
|
|
|
16
22
|
@ReactMethod
|
|
@@ -32,7 +38,7 @@ class NamiEntitlementManagerBridgeModule(reactContext: ReactApplicationContext)
|
|
|
32
38
|
}
|
|
33
39
|
|
|
34
40
|
@ReactMethod
|
|
35
|
-
fun refresh(
|
|
41
|
+
fun refresh() {
|
|
36
42
|
NamiEntitlementManager.refresh { activeNativeEntitlements ->
|
|
37
43
|
val resultArray: WritableArray = WritableNativeArray()
|
|
38
44
|
if (activeNativeEntitlements != null) {
|
|
@@ -42,7 +48,9 @@ class NamiEntitlementManagerBridgeModule(reactContext: ReactApplicationContext)
|
|
|
42
48
|
}
|
|
43
49
|
}
|
|
44
50
|
}
|
|
45
|
-
|
|
51
|
+
reactApplicationContext
|
|
52
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
53
|
+
.emit("EntitlementsChanged", resultArray)
|
|
46
54
|
}
|
|
47
55
|
}
|
|
48
56
|
|
|
@@ -68,9 +76,11 @@ class NamiEntitlementManagerBridgeModule(reactContext: ReactApplicationContext)
|
|
|
68
76
|
|
|
69
77
|
@ReactMethod
|
|
70
78
|
fun addListener(eventName: String?) {
|
|
79
|
+
// Required for React Native event emitter support
|
|
71
80
|
}
|
|
72
81
|
|
|
73
82
|
@ReactMethod
|
|
74
83
|
fun removeListeners(count: Int?) {
|
|
84
|
+
// Required for React Native event emitter support
|
|
75
85
|
}
|
|
76
86
|
}
|