react-native-nami-sdk 3.2.11 → 3.3.0-2
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 +26 -32
- 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} +1 -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 +41 -11
- package/dist/src/version.d.ts +5 -0
- package/index.ts +1 -2
- package/ios/Nami.m +8 -88
- package/ios/Nami.swift +85 -0
- package/ios/NamiCampaignManagerBridge.m +3 -3
- package/ios/NamiCampaignManagerBridge.swift +50 -62
- 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 +20 -0
- package/ios/NamiFlowManagerBridge.swift +57 -0
- 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 +68 -58
- package/src/NamiEntitlementManager.ts +49 -36
- package/src/NamiFlowManager.ts +56 -0
- 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 -386
- package/.github/workflows/build.yml +0 -70
- package/.pre-commit-config.yaml +0 -24
- package/.prettierrc.js +0 -7
- package/android/.project +0 -17
- package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
- 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 -50
- 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/ios/RNNami.xcodeproj/project.pbxproj +0 -365
- package/ios/RNNami.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/RNNami.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/RNNami.xcodeproj/xcshareddata/xcschemes/RNNami.xcscheme +0 -67
- package/ios/RNNami.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/RNNami.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/src/Nami.d.ts +0 -8
- package/src/NamiCampaignManager.d.ts +0 -18
- package/src/NamiEntitlementManager.d.ts +0 -15
- 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
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
package com.nami.reactlibrary;
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.ReactPackage;
|
|
4
|
-
import com.facebook.react.bridge.JavaScriptModule;
|
|
5
|
-
import com.facebook.react.bridge.NativeModule;
|
|
6
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
-
import com.facebook.react.shell.MainReactPackage;
|
|
8
|
-
import com.facebook.react.uimanager.ViewManager;
|
|
9
|
-
|
|
10
|
-
import org.jetbrains.annotations.NotNull;
|
|
11
|
-
|
|
12
|
-
import java.util.ArrayList;
|
|
13
|
-
import java.util.Arrays;
|
|
14
|
-
import java.util.Collections;
|
|
15
|
-
import java.util.List;
|
|
16
|
-
|
|
17
|
-
public class NamiBridgePackage implements ReactPackage {
|
|
18
|
-
@NotNull
|
|
19
|
-
@Override
|
|
20
|
-
public List<NativeModule> createNativeModules(@NotNull ReactApplicationContext reactContext) {
|
|
21
|
-
List<NativeModule> moduleList = new ArrayList<NativeModule>();
|
|
22
|
-
moduleList.add(new NamiBridgeModule(reactContext));
|
|
23
|
-
moduleList.add(new NamiPaywallManagerBridgeModule(reactContext));
|
|
24
|
-
moduleList.add(new NamiPurchaseManagerBridgeModule(reactContext));
|
|
25
|
-
moduleList.add(new NamiEntitlementManagerBridgeModule(reactContext));
|
|
26
|
-
moduleList.add(new NamiMLManagerBridgeModule(reactContext));
|
|
27
|
-
moduleList.add(new NamiManagerBridgeModule(reactContext));
|
|
28
|
-
moduleList.add(new NamiCustomerManagerBridgeModule(reactContext));
|
|
29
|
-
moduleList.add(new NamiCampaignManagerBridgeModule(reactContext));
|
|
30
|
-
|
|
31
|
-
return moduleList;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public List<Class<? extends JavaScriptModule>> createJSModules() {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
@NotNull
|
|
39
|
-
@Override
|
|
40
|
-
public List<ViewManager> createViewManagers(@NotNull ReactApplicationContext reactContext) {
|
|
41
|
-
return Collections.emptyList();
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
protected List<ReactPackage> getPackages() {
|
|
45
|
-
return Arrays.asList(
|
|
46
|
-
new MainReactPackage(),
|
|
47
|
-
new NamiBridgePackage()
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
package com.nami.reactlibrary
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
5
|
-
import com.facebook.react.bridge.ReactMethod
|
|
6
|
-
import com.facebook.react.bridge.ReadableArray
|
|
7
|
-
import com.namiml.ml.NamiMLManager
|
|
8
|
-
|
|
9
|
-
class NamiMLManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
10
|
-
ReactContextBaseJavaModule(reactContext) {
|
|
11
|
-
|
|
12
|
-
override fun getName(): String {
|
|
13
|
-
return "NamiMLManagerBridge"
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
@ReactMethod
|
|
17
|
-
fun enterCoreContentWithLabels(labels: ReadableArray) {
|
|
18
|
-
reactApplicationContext.runOnUiQueueThread {
|
|
19
|
-
NamiMLManager.enterCoreContent(labels.toArrayList().filterIsInstance<String>())
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@ReactMethod
|
|
24
|
-
fun enterCoreContentWithLabel(label: String) {
|
|
25
|
-
reactApplicationContext.runOnUiQueueThread {
|
|
26
|
-
NamiMLManager.enterCoreContent(label)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@ReactMethod
|
|
31
|
-
fun exitCoreContentWithLabels(labels: ReadableArray) {
|
|
32
|
-
reactApplicationContext.runOnUiQueueThread {
|
|
33
|
-
NamiMLManager.exitCoreContent(labels.toArrayList().filterIsInstance<String>())
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
@ReactMethod
|
|
38
|
-
fun exitCoreContentWithLabel(label: String) {
|
|
39
|
-
reactApplicationContext.runOnUiQueueThread {
|
|
40
|
-
NamiMLManager.exitCoreContent(label)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
@ReactMethod
|
|
45
|
-
fun coreActionWithLabel(label: String) {
|
|
46
|
-
reactApplicationContext.runOnUiQueueThread {
|
|
47
|
-
NamiMLManager.coreAction(label)
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
@ReactMethod
|
|
52
|
-
fun addListener(eventName: String?) {
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
@ReactMethod
|
|
56
|
-
fun removeListeners(count: Int?) {
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
package com.nami.reactlibrary
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.bridge.*
|
|
4
|
-
import com.namiml.Nami
|
|
5
|
-
|
|
6
|
-
class NamiManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
7
|
-
ReactContextBaseJavaModule(reactContext) {
|
|
8
|
-
|
|
9
|
-
override fun getName(): String {
|
|
10
|
-
return "RNNamiManager"
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
@ReactMethod
|
|
14
|
-
fun sdkConfigured(promise: Promise) {
|
|
15
|
-
val sdkConfigured = Nami.isInitialized()
|
|
16
|
-
promise.resolve(sdkConfigured)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@ReactMethod
|
|
20
|
-
fun addListener(eventName: String?) {
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
@ReactMethod
|
|
24
|
-
fun removeListeners(count: Int?) {
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
package com.nami.reactlibrary
|
|
2
|
-
|
|
3
|
-
import android.app.Activity
|
|
4
|
-
import android.content.Intent
|
|
5
|
-
import android.util.Log
|
|
6
|
-
import com.facebook.react.bridge.*
|
|
7
|
-
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
8
|
-
import com.namiml.paywall.NamiPaywallManager
|
|
9
|
-
import com.namiml.paywall.NamiPurchaseSource
|
|
10
|
-
import com.namiml.paywall.NamiSKU
|
|
11
|
-
import com.namiml.paywall.NamiSKUType
|
|
12
|
-
import com.namiml.paywall.model.NamiPurchaseSuccess
|
|
13
|
-
import java.util.*
|
|
14
|
-
|
|
15
|
-
class NamiPaywallManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
16
|
-
ReactContextBaseJavaModule(reactContext), ActivityEventListener {
|
|
17
|
-
|
|
18
|
-
var latestPaywallActivity: Activity? = null
|
|
19
|
-
|
|
20
|
-
override fun getName(): String {
|
|
21
|
-
return "RNNamiPaywallManager"
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
@ReactMethod
|
|
25
|
-
fun buySkuComplete(dict: ReadableMap, storeType: String) {
|
|
26
|
-
var product: ReadableMap? = null
|
|
27
|
-
var productId: String? = null
|
|
28
|
-
var skuRefId: String? = null
|
|
29
|
-
var typeString: String? = null
|
|
30
|
-
|
|
31
|
-
var skuType: NamiSKUType?
|
|
32
|
-
|
|
33
|
-
var purchaseToken: String? = null
|
|
34
|
-
var orderId: String? = null
|
|
35
|
-
|
|
36
|
-
var receiptId: String? = null
|
|
37
|
-
var localizedPrice: String? = null
|
|
38
|
-
var userId: String? = null
|
|
39
|
-
var marketplace: String? = null
|
|
40
|
-
|
|
41
|
-
if (dict.hasKey("product")) {
|
|
42
|
-
product = dict.getMap("product")
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (product != null) {
|
|
46
|
-
if (product.hasKey("id")) {
|
|
47
|
-
productId = product.getString("id")
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (product.hasKey("skuId")) {
|
|
51
|
-
skuRefId = product.getString("skuId")
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (product.hasKey("type")) {
|
|
55
|
-
typeString = product.getString("type")
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (productId != null && skuRefId != null) {
|
|
60
|
-
val namiSku = NamiSKU.create(
|
|
61
|
-
skuRefId = skuRefId,
|
|
62
|
-
skuId = productId,
|
|
63
|
-
)
|
|
64
|
-
var purchaseSuccess: NamiPurchaseSuccess? = null
|
|
65
|
-
|
|
66
|
-
if (storeType == "GooglePlay") {
|
|
67
|
-
if (dict.hasKey("purchaseToken")) {
|
|
68
|
-
purchaseToken = dict.getString("purchaseToken")
|
|
69
|
-
}
|
|
70
|
-
if (dict.hasKey("orderId")) {
|
|
71
|
-
orderId = dict.getString("orderId")
|
|
72
|
-
}
|
|
73
|
-
Log.d(LOG_TAG, "$namiSku $purchaseToken $orderId")
|
|
74
|
-
|
|
75
|
-
if (namiSku != null && purchaseToken != null && orderId != null) {
|
|
76
|
-
purchaseSuccess = NamiPurchaseSuccess.GooglePlay(
|
|
77
|
-
product = namiSku,
|
|
78
|
-
orderId = orderId,
|
|
79
|
-
purchaseToken = purchaseToken,
|
|
80
|
-
)
|
|
81
|
-
}
|
|
82
|
-
} else if (storeType == "Amazon") {
|
|
83
|
-
if (dict.hasKey("receiptId")) {
|
|
84
|
-
receiptId = dict.getString("receiptId")
|
|
85
|
-
}
|
|
86
|
-
if (dict.hasKey("localizedPrice")) {
|
|
87
|
-
localizedPrice = dict.getString("localizedPrice")
|
|
88
|
-
}
|
|
89
|
-
if (dict.hasKey("userId")) {
|
|
90
|
-
userId = dict.getString("userId")
|
|
91
|
-
}
|
|
92
|
-
if (dict.hasKey("marketplace")) {
|
|
93
|
-
marketplace = dict.getString("marketplace")
|
|
94
|
-
}
|
|
95
|
-
if (namiSku != null && receiptId != null && localizedPrice != null && userId != null && marketplace != null) {
|
|
96
|
-
purchaseSuccess = NamiPurchaseSuccess.Amazon(
|
|
97
|
-
product = namiSku,
|
|
98
|
-
receiptId = receiptId,
|
|
99
|
-
localizedPrice = localizedPrice,
|
|
100
|
-
userId = userId,
|
|
101
|
-
marketplace = marketplace,
|
|
102
|
-
)
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (purchaseSuccess != null) {
|
|
107
|
-
if (latestPaywallActivity != null) {
|
|
108
|
-
NamiPaywallManager.buySkuComplete(latestPaywallActivity!!, purchaseSuccess)
|
|
109
|
-
} else {
|
|
110
|
-
NamiPaywallManager.buySkuComplete(currentActivity!!, purchaseSuccess)
|
|
111
|
-
}
|
|
112
|
-
} else {
|
|
113
|
-
Log.d(LOG_TAG, "Unable to create a valid NamiPurchaseSuccess object, so buySkuComplete will not succeed. Paywall conversion will not be reported for this purchase.")
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
@ReactMethod
|
|
119
|
-
fun registerCloseHandler() {
|
|
120
|
-
NamiPaywallManager.registerCloseHandler { activity ->
|
|
121
|
-
latestPaywallActivity = activity
|
|
122
|
-
val map = Arguments.createMap().apply {
|
|
123
|
-
putBoolean("paywallCloseRequested", true)
|
|
124
|
-
}
|
|
125
|
-
reactApplicationContext
|
|
126
|
-
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
127
|
-
.emit("PaywallCloseRequested", map)
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
@ReactMethod
|
|
132
|
-
fun dismiss(promise: Promise) {
|
|
133
|
-
if (latestPaywallActivity != null) {
|
|
134
|
-
val paywallActivity = latestPaywallActivity as Activity
|
|
135
|
-
NamiPaywallManager.dismiss(paywallActivity, completionHandler = {
|
|
136
|
-
promise.resolve(it)
|
|
137
|
-
})
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
@ReactMethod
|
|
142
|
-
fun registerBuySkuHandler() {
|
|
143
|
-
NamiPaywallManager.registerBuySkuHandler { activity, sku ->
|
|
144
|
-
latestPaywallActivity = activity
|
|
145
|
-
val dictionary = sku.toSkuDict()
|
|
146
|
-
reactApplicationContext
|
|
147
|
-
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
148
|
-
.emit("RegisterBuySKU", dictionary)
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
@ReactMethod
|
|
153
|
-
fun registerSignInHandler() {
|
|
154
|
-
NamiPaywallManager.registerSignInHandler { activity ->
|
|
155
|
-
latestPaywallActivity = activity
|
|
156
|
-
val map = Arguments.createMap().apply {
|
|
157
|
-
putBoolean("paywallSignInRequested", true)
|
|
158
|
-
}
|
|
159
|
-
reactApplicationContext
|
|
160
|
-
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
161
|
-
.emit("PaywallSignInRequested", map)
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
@ReactMethod
|
|
166
|
-
fun registerRestoreHandler() {
|
|
167
|
-
NamiPaywallManager.registerRestoreHandler { activity ->
|
|
168
|
-
latestPaywallActivity = activity
|
|
169
|
-
val map = Arguments.createMap().apply {
|
|
170
|
-
putBoolean("paywallRestoreRequested", true)
|
|
171
|
-
}
|
|
172
|
-
reactApplicationContext
|
|
173
|
-
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
174
|
-
.emit("PaywallRestoreRequested", map)
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
@ReactMethod
|
|
179
|
-
fun registerDeeplinkActionHandler() {
|
|
180
|
-
NamiPaywallManager.registerDeepLinkHandler { activity, url ->
|
|
181
|
-
latestPaywallActivity = activity
|
|
182
|
-
reactApplicationContext
|
|
183
|
-
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
184
|
-
.emit("PaywallDeeplinkAction", url)
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
@ReactMethod
|
|
189
|
-
fun show() {
|
|
190
|
-
// Do nothing on Android side
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
@ReactMethod
|
|
194
|
-
fun hide() {
|
|
195
|
-
// Do nothing on Android side
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
@ReactMethod
|
|
199
|
-
fun isHidden(promise: Promise) {
|
|
200
|
-
// Do nothing on Android side
|
|
201
|
-
promise.resolve(false)
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
@ReactMethod
|
|
205
|
-
fun isPaywallOpen(promise: Promise) {
|
|
206
|
-
val paywallOpen = NamiPaywallManager.isPaywallOpen()
|
|
207
|
-
promise.resolve(paywallOpen)
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
@ReactMethod
|
|
211
|
-
fun buySkuCancel() {
|
|
212
|
-
reactApplicationContext.runOnUiQueueThread {
|
|
213
|
-
if (latestPaywallActivity != null) {
|
|
214
|
-
NamiPaywallManager.buySkuCancel(latestPaywallActivity!!)
|
|
215
|
-
} else if (currentActivity != null) {
|
|
216
|
-
NamiPaywallManager.buySkuCancel(currentActivity!!)
|
|
217
|
-
} else {
|
|
218
|
-
NamiPaywallManager.buySkuCancel()
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
@ReactMethod
|
|
224
|
-
fun setProductDetails(productDetails: String, allowOffers: Boolean) {
|
|
225
|
-
NamiPaywallManager.setProductDetails(productDetails, allowOffers = allowOffers)
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
@ReactMethod
|
|
229
|
-
fun setAppSuppliedVideoDetails(url: String, name: String?) {
|
|
230
|
-
NamiPaywallManager.setAppSuppliedVideoDetails(url = url, name = name)
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
@ReactMethod
|
|
234
|
-
fun allowUserInteraction(allowed: Boolean) {
|
|
235
|
-
NamiPaywallManager.allowPaywallInteraction(allow = allowed)
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
@ReactMethod
|
|
239
|
-
fun addListener(eventName: String?) {
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
@ReactMethod
|
|
243
|
-
fun removeListeners(count: Int?) {
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
override fun onActivityResult(
|
|
247
|
-
activity: Activity?,
|
|
248
|
-
requestCode: Int,
|
|
249
|
-
resultCode: Int,
|
|
250
|
-
data: Intent?,
|
|
251
|
-
) {
|
|
252
|
-
Log.d(LOG_TAG, "Nami Activity result listener activated, code is $requestCode")
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
override fun onNewIntent(intent: Intent?) {
|
|
256
|
-
// do nothing
|
|
257
|
-
}
|
|
258
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
package com.nami.reactlibrary
|
|
2
|
-
|
|
3
|
-
import android.util.Log
|
|
4
|
-
import com.facebook.react.bridge.*
|
|
5
|
-
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
6
|
-
import com.namiml.billing.NamiPurchaseManager
|
|
7
|
-
|
|
8
|
-
class NamiPurchaseManagerBridgeModule(reactContext: ReactApplicationContext) :
|
|
9
|
-
ReactContextBaseJavaModule(reactContext) {
|
|
10
|
-
|
|
11
|
-
override fun getName(): String {
|
|
12
|
-
return "RNNamiPurchaseManager"
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
@ReactMethod
|
|
16
|
-
fun purchases(resultsCallback: Callback) {
|
|
17
|
-
reactApplicationContext.runOnUiQueueThread {
|
|
18
|
-
val purchases = NamiPurchaseManager.allPurchases()
|
|
19
|
-
|
|
20
|
-
// Pass back empty array until we can get purchases from the SDK
|
|
21
|
-
val resultArray: WritableArray = WritableNativeArray()
|
|
22
|
-
|
|
23
|
-
for (purchase in purchases) {
|
|
24
|
-
resultArray.pushMap(purchase.toPurchaseDict())
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
resultsCallback.invoke(resultArray)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@ReactMethod
|
|
32
|
-
fun skuPurchased(skuID: String, promise: Promise) {
|
|
33
|
-
val isPurchased = NamiPurchaseManager.isSKUIDPurchased(skuID)
|
|
34
|
-
promise.resolve(isPurchased)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
@ReactMethod
|
|
38
|
-
fun consumePurchasedSku(skuRefId: String) {
|
|
39
|
-
reactApplicationContext.runOnUiQueueThread {
|
|
40
|
-
NamiPurchaseManager.consumePurchasedSKU(skuRefId)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
@ReactMethod
|
|
45
|
-
fun anySkuPurchased(skuIDs: ReadableArray, promise: Promise) {
|
|
46
|
-
reactApplicationContext.runOnUiQueueThread {
|
|
47
|
-
val checkArray: MutableList<String> = mutableListOf()
|
|
48
|
-
for (x in 0 until skuIDs.size()) {
|
|
49
|
-
if (skuIDs.getType(x) == ReadableType.String) {
|
|
50
|
-
val skuID = skuIDs.getString(x)
|
|
51
|
-
if (skuID != null && skuID.isNotEmpty()) {
|
|
52
|
-
checkArray.add(skuID)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
val anyPurchased = NamiPurchaseManager.anySKUIDPurchased(checkArray)
|
|
58
|
-
|
|
59
|
-
promise.resolve(anyPurchased)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
@ReactMethod
|
|
64
|
-
fun restorePurchases(resultsCallback: Callback) {
|
|
65
|
-
Log.w(LOG_TAG, "Restore Purchases called on Android platform, has no effect on Android.")
|
|
66
|
-
|
|
67
|
-
val resultMap = WritableNativeMap().apply {
|
|
68
|
-
putBoolean("success", false)
|
|
69
|
-
putString(
|
|
70
|
-
"error",
|
|
71
|
-
"Google Play or Amazon Appstore on Android devices do not provide an API method to restore purchases.",
|
|
72
|
-
)
|
|
73
|
-
}
|
|
74
|
-
resultsCallback.invoke(resultMap)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
@ReactMethod
|
|
78
|
-
fun registerPurchasesChangedHandler() {
|
|
79
|
-
NamiPurchaseManager.registerPurchasesChangedHandler { purchases, purchaseState, error ->
|
|
80
|
-
run {
|
|
81
|
-
val resultPurchases: WritableArray = WritableNativeArray()
|
|
82
|
-
|
|
83
|
-
for (purchase in purchases) {
|
|
84
|
-
resultPurchases.pushMap(purchase.toPurchaseDict())
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
val stateString = purchaseState.toString()
|
|
88
|
-
|
|
89
|
-
val payload = Arguments.createMap()
|
|
90
|
-
payload.putArray("purchases", resultPurchases)
|
|
91
|
-
payload.putString("purchaseState", stateString)
|
|
92
|
-
payload.putString("error", error)
|
|
93
|
-
|
|
94
|
-
reactApplicationContext
|
|
95
|
-
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
96
|
-
.emit("PurchasesChanged", payload)
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
@ReactMethod
|
|
102
|
-
fun addListener(eventName: String?) {
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
@ReactMethod
|
|
106
|
-
fun removeListeners(count: Int?) {
|
|
107
|
-
}
|
|
108
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/python3
|
|
2
|
-
|
|
3
|
-
import sys
|
|
4
|
-
import getopt
|
|
5
|
-
import json
|
|
6
|
-
|
|
7
|
-
from google.auth.exceptions import DefaultCredentialsError
|
|
8
|
-
from google.oauth2 import service_account
|
|
9
|
-
from googleapiclient import discovery, errors
|
|
10
|
-
|
|
11
|
-
from pyasn1.error import SubstrateUnderrunError
|
|
12
|
-
|
|
13
|
-
def printv(text):
|
|
14
|
-
if show_output:
|
|
15
|
-
print(text)
|
|
16
|
-
|
|
17
|
-
def create_edit(service, package_name):
|
|
18
|
-
printv(f"Create an edit for the package {package_name}")
|
|
19
|
-
try:
|
|
20
|
-
edit_request = service.edits().insert(body={}, packageName=package_name)
|
|
21
|
-
edit_response = edit_request.execute()
|
|
22
|
-
printv(f"Created edit {edit_response} for package {package_name}")
|
|
23
|
-
except (errors.Error, errors.HttpError) as e:
|
|
24
|
-
raise(f"Error creating edit {e}")
|
|
25
|
-
else:
|
|
26
|
-
if "id" in edit_response:
|
|
27
|
-
return edit_response["id"]
|
|
28
|
-
|
|
29
|
-
def delete_edit(service, package_name, edit_id):
|
|
30
|
-
printv(f"Delete an edit for the package {package_name}")
|
|
31
|
-
try:
|
|
32
|
-
delete_request = service.edits().delete(packageName=package_name, editId=edit_id)
|
|
33
|
-
delete_response = delete_request.execute()
|
|
34
|
-
printv(f"Deleted edit {delete_response} for package {package_name}")
|
|
35
|
-
except (errors.Error, errors.HttpError) as e:
|
|
36
|
-
raise(f"Error deleting edit {e}")
|
|
37
|
-
|
|
38
|
-
def get_credentials_response(service_credentials_path):
|
|
39
|
-
try:
|
|
40
|
-
credentials_response = service_account.Credentials.from_service_account_file(
|
|
41
|
-
service_credentials_path)
|
|
42
|
-
except ValueError as error:
|
|
43
|
-
printv(f"401: {error}")
|
|
44
|
-
return None
|
|
45
|
-
except DefaultCredentialsError as error:
|
|
46
|
-
printv(f"401: {error}")
|
|
47
|
-
return None
|
|
48
|
-
except SubstrateUnderrunError as error:
|
|
49
|
-
printv(f"401: The service credentials are malformed")
|
|
50
|
-
return None
|
|
51
|
-
|
|
52
|
-
if type(credentials_response) is service_account.Credentials:
|
|
53
|
-
return credentials_response
|
|
54
|
-
else:
|
|
55
|
-
printv(f"401: Unknown error with service account credentials.")
|
|
56
|
-
return None
|
|
57
|
-
|
|
58
|
-
def get_track(service, package_name, edit_id, track_name):
|
|
59
|
-
request = (
|
|
60
|
-
service.edits().tracks()
|
|
61
|
-
.get(packageName=package_name, editId=edit_id, track=track_name)
|
|
62
|
-
)
|
|
63
|
-
try:
|
|
64
|
-
response = request.execute()
|
|
65
|
-
except errors.HttpError as error:
|
|
66
|
-
error_content = json.loads(error.content)
|
|
67
|
-
if "error" in error_content:
|
|
68
|
-
error = error_content["error"]
|
|
69
|
-
|
|
70
|
-
if "code" in error:
|
|
71
|
-
status_code = error["code"]
|
|
72
|
-
else:
|
|
73
|
-
status_code = 000
|
|
74
|
-
|
|
75
|
-
if "message" in error:
|
|
76
|
-
message = error["message"]
|
|
77
|
-
else:
|
|
78
|
-
message = "Unknown error"
|
|
79
|
-
|
|
80
|
-
printv(f"{status_code}: {message}")
|
|
81
|
-
else:
|
|
82
|
-
printv(f"200: API request was successful")
|
|
83
|
-
printv(response)
|
|
84
|
-
version_codes = []
|
|
85
|
-
if "releases" in response:
|
|
86
|
-
releases = response["releases"]
|
|
87
|
-
for release in releases:
|
|
88
|
-
if "versionCodes" in release:
|
|
89
|
-
all_codes = release["versionCodes"]
|
|
90
|
-
for code in all_codes:
|
|
91
|
-
printv(code)
|
|
92
|
-
if code in version_codes:
|
|
93
|
-
pass
|
|
94
|
-
else:
|
|
95
|
-
version_codes.append(int(code))
|
|
96
|
-
|
|
97
|
-
printv(f"observed codes: {version_codes}")
|
|
98
|
-
new_version = max(version_codes)+1
|
|
99
|
-
print(f"{new_version}")
|
|
100
|
-
with open(".new_version_code", "w") as f:
|
|
101
|
-
f.write(
|
|
102
|
-
f"{new_version}"
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
def get_version_code(service_credentials_path, package_name, track_name):
|
|
106
|
-
credentials = get_credentials_response(service_credentials_path)
|
|
107
|
-
|
|
108
|
-
service = discovery.build(
|
|
109
|
-
"androidpublisher", "v3", credentials=credentials, cache_discovery=False
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
edit_id = create_edit(service, package_name)
|
|
113
|
-
get_track(service, package_name, edit_id, track_name)
|
|
114
|
-
delete_edit(service, package_name, edit_id)
|
|
115
|
-
|
|
116
|
-
if __name__ == "__main__":
|
|
117
|
-
help_message = "get_version_code.py /path/to/service_credentials.json [package_name] [track_name] <OPTIONAL: --quiet>"
|
|
118
|
-
|
|
119
|
-
if len(sys.argv) < 4:
|
|
120
|
-
print(help_message)
|
|
121
|
-
sys.exit(2)
|
|
122
|
-
|
|
123
|
-
service_credentials = sys.argv[1]
|
|
124
|
-
|
|
125
|
-
package_name = sys.argv[2]
|
|
126
|
-
track_name = sys.argv[3]
|
|
127
|
-
|
|
128
|
-
show_output = True
|
|
129
|
-
|
|
130
|
-
try:
|
|
131
|
-
opts, args = getopt.getopt(sys.argv[4:], "", ["quiet"])
|
|
132
|
-
except getopt.GetoptError:
|
|
133
|
-
print(help_message)
|
|
134
|
-
sys.exit(2)
|
|
135
|
-
|
|
136
|
-
for opt, arg in opts:
|
|
137
|
-
if opt in ("--quiet"):
|
|
138
|
-
show_output = False
|
|
139
|
-
|
|
140
|
-
get_version_code(service_credentials, package_name, track_name)
|
package/build-utils/preflight.py
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import json
|
|
3
|
-
import sys
|
|
4
|
-
import re
|
|
5
|
-
import subprocess
|
|
6
|
-
|
|
7
|
-
# Regex to validate version numbers
|
|
8
|
-
PROD_VERSION_RE = re.compile(r"^\d+\.\d+\.\d+$")
|
|
9
|
-
PROD_VERSION_EXT_RE = re.compile(r"^\d+\.\d+\.\d+-\d$")
|
|
10
|
-
PRERELEASE_VERSION_RE = re.compile(r"^\d+\.\d+\.\d+-(alpha|beta|rc)\.\d+$")
|
|
11
|
-
|
|
12
|
-
early_access = str(os.getenv("EARLY_ACCESS"))
|
|
13
|
-
|
|
14
|
-
# get the version out of source of truth
|
|
15
|
-
with open("package.json", "r") as f:
|
|
16
|
-
package = json.load(f)
|
|
17
|
-
nami_sdk_version = package["version"]
|
|
18
|
-
|
|
19
|
-
# Get git version
|
|
20
|
-
git_long_hash = (
|
|
21
|
-
subprocess.check_output(["git", "log", "-1", "--format=%H"]).decode("utf-8").strip()
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
# Check what kind of release this is and guard against non-conforming version numbers
|
|
25
|
-
if PROD_VERSION_RE.match(nami_sdk_version) or PROD_VERSION_EXT_RE.match(nami_sdk_version):
|
|
26
|
-
if early_access == "true":
|
|
27
|
-
print(f"Early access value ('{early_access}') is not compatible with production version format '{nami_sdk_version}'")
|
|
28
|
-
sys.exit(1)
|
|
29
|
-
type_mods = ""
|
|
30
|
-
elif PRERELEASE_VERSION_RE.match(nami_sdk_version):
|
|
31
|
-
if early_access == "false":
|
|
32
|
-
print(f"Early access value ('{early_access}') is not compatible with early access version format '{nami_sdk_version}'")
|
|
33
|
-
sys.exit(1)
|
|
34
|
-
type_mods = "--prerelease"
|
|
35
|
-
else:
|
|
36
|
-
print(f"SDK version '{nami_sdk_version}' does not conform to version spec")
|
|
37
|
-
sys.exit(1)
|
|
38
|
-
|
|
39
|
-
# generate a shell command to create a release later
|
|
40
|
-
with open("gh-release-command.sh", "w") as f:
|
|
41
|
-
f.write(
|
|
42
|
-
f"gh release create --generate-notes --title v{nami_sdk_version} {type_mods} --target {git_long_hash} v{nami_sdk_version}"
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
# report our status
|
|
46
|
-
print(f"Identified Version: {nami_sdk_version}")
|