mobilyflow-react-native-sdk 0.0.3 → 0.1.0-alpha.1
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/MobilyflowReactNativeSdk.podspec +1 -1
- package/android/build.gradle +1 -1
- package/android/generated/java/com/mobilyflowreactnativesdk/NativeMobilyflowReactNativeSdkSpec.java +6 -2
- package/android/generated/jni/RNMobilyflowReactNativeSdkSpec-generated.cpp +10 -4
- package/android/generated/jni/react/renderer/components/RNMobilyflowReactNativeSdkSpec/RNMobilyflowReactNativeSdkSpecJSI-generated.cpp +13 -4
- package/android/generated/jni/react/renderer/components/RNMobilyflowReactNativeSdkSpec/RNMobilyflowReactNativeSdkSpecJSI.h +19 -10
- package/android/src/main/java/com/mobilyflowreactnativesdk/MobilyflowReactNativeSdkModule.kt +9 -6
- package/ios/MobilyflowReactNativeSdk.mm +30 -24
- package/ios/generated/RNMobilyflowReactNativeSdkSpec/RNMobilyflowReactNativeSdkSpec-generated.mm +11 -4
- package/ios/generated/RNMobilyflowReactNativeSdkSpec/RNMobilyflowReactNativeSdkSpec.h +5 -0
- package/ios/generated/RNMobilyflowReactNativeSdkSpecJSI-generated.cpp +13 -4
- package/ios/generated/RNMobilyflowReactNativeSdkSpecJSI.h +19 -10
- package/package.json +1 -1
- package/src/NativeMobilyflowReactNativeSdk.ts +7 -2
- package/src/index.tsx +12 -4
@@ -21,7 +21,7 @@ Pod::Spec.new do |s|
|
|
21
21
|
s.swift_versions = '5.0'
|
22
22
|
|
23
23
|
# Install MobilyFlow SDK
|
24
|
-
s.dependency 'MobilyflowSDK', '
|
24
|
+
s.dependency 'MobilyflowSDK', '0.1.0'
|
25
25
|
|
26
26
|
#s.subspec 'MobilyflowSDK' do |ss|
|
27
27
|
# ss.source_files = '../mobilyflow-ios-sdk/Sources/MobilyflowSDK/**/*'
|
package/android/build.gradle
CHANGED
@@ -100,7 +100,7 @@ def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
100
100
|
dependencies {
|
101
101
|
implementation "com.facebook.react:react-android"
|
102
102
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
103
|
-
implementation "com.mobilyflow:mobilyflow-android-sdk:0.0
|
103
|
+
implementation "com.mobilyflow:mobilyflow-android-sdk:0.1.0"
|
104
104
|
implementation "org.jetbrains.kotlinx:kotlinx-datetime:0.6.2"
|
105
105
|
implementation "org.jetbrains.kotlin:kotlin-reflect"
|
106
106
|
}
|
package/android/generated/java/com/mobilyflowreactnativesdk/NativeMobilyflowReactNativeSdkSpec.java
CHANGED
@@ -49,11 +49,11 @@ public abstract class NativeMobilyflowReactNativeSdkSpec extends ReactContextBas
|
|
49
49
|
|
50
50
|
@ReactMethod
|
51
51
|
@DoNotStrip
|
52
|
-
public abstract void getProducts(String uuid,
|
52
|
+
public abstract void getProducts(String uuid, ReadableArray identifiers, boolean onlyAvailable, Promise promise);
|
53
53
|
|
54
54
|
@ReactMethod
|
55
55
|
@DoNotStrip
|
56
|
-
public abstract void getSubscriptionGroups(String uuid,
|
56
|
+
public abstract void getSubscriptionGroups(String uuid, ReadableArray identifiers, boolean onlyAvailable, Promise promise);
|
57
57
|
|
58
58
|
@ReactMethod
|
59
59
|
@DoNotStrip
|
@@ -90,4 +90,8 @@ public abstract class NativeMobilyflowReactNativeSdkSpec extends ReactContextBas
|
|
90
90
|
@ReactMethod
|
91
91
|
@DoNotStrip
|
92
92
|
public abstract void getStoreCountry(String uuid, Promise promise);
|
93
|
+
|
94
|
+
@ReactMethod
|
95
|
+
@DoNotStrip
|
96
|
+
public abstract void isForwardingEnable(String uuid, Promise promise);
|
93
97
|
}
|
@@ -29,12 +29,12 @@ static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI
|
|
29
29
|
|
30
30
|
static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getProducts(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
31
31
|
static jmethodID cachedMethodId = nullptr;
|
32
|
-
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "getProducts", "(Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;
|
32
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "getProducts", "(Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;ZLcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
33
33
|
}
|
34
34
|
|
35
35
|
static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getSubscriptionGroups(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
36
36
|
static jmethodID cachedMethodId = nullptr;
|
37
|
-
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "getSubscriptionGroups", "(Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;
|
37
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "getSubscriptionGroups", "(Ljava/lang/String;Lcom/facebook/react/bridge/ReadableArray;ZLcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
38
38
|
}
|
39
39
|
|
40
40
|
static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getEntitlementForSubscription(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
@@ -82,13 +82,18 @@ static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI
|
|
82
82
|
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "getStoreCountry", "(Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
83
83
|
}
|
84
84
|
|
85
|
+
static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_isForwardingEnable(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
86
|
+
static jmethodID cachedMethodId = nullptr;
|
87
|
+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "isForwardingEnable", "(Ljava/lang/String;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
|
88
|
+
}
|
89
|
+
|
85
90
|
NativeMobilyflowReactNativeSdkSpecJSI::NativeMobilyflowReactNativeSdkSpecJSI(const JavaTurboModule::InitParams ¶ms)
|
86
91
|
: JavaTurboModule(params) {
|
87
92
|
methodMap_["instantiate"] = MethodMetadata {4, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_instantiate};
|
88
93
|
methodMap_["close"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_close};
|
89
94
|
methodMap_["login"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_login};
|
90
|
-
methodMap_["getProducts"] = MethodMetadata {
|
91
|
-
methodMap_["getSubscriptionGroups"] = MethodMetadata {
|
95
|
+
methodMap_["getProducts"] = MethodMetadata {3, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getProducts};
|
96
|
+
methodMap_["getSubscriptionGroups"] = MethodMetadata {3, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getSubscriptionGroups};
|
92
97
|
methodMap_["getEntitlementForSubscription"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getEntitlementForSubscription};
|
93
98
|
methodMap_["getEntitlement"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getEntitlement};
|
94
99
|
methodMap_["getEntitlements"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getEntitlements};
|
@@ -98,6 +103,7 @@ NativeMobilyflowReactNativeSdkSpecJSI::NativeMobilyflowReactNativeSdkSpecJSI(con
|
|
98
103
|
methodMap_["purchaseProduct"] = MethodMetadata {3, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_purchaseProduct};
|
99
104
|
methodMap_["sendDiagnotic"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_sendDiagnotic};
|
100
105
|
methodMap_["getStoreCountry"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getStoreCountry};
|
106
|
+
methodMap_["isForwardingEnable"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_isForwardingEnable};
|
101
107
|
}
|
102
108
|
|
103
109
|
std::shared_ptr<TurboModule> RNMobilyflowReactNativeSdkSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) {
|
@@ -38,14 +38,16 @@ static jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getPro
|
|
38
38
|
return static_cast<NativeMobilyflowReactNativeSdkCxxSpecJSI *>(&turboModule)->getProducts(
|
39
39
|
rt,
|
40
40
|
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
41
|
-
count <= 1
|
41
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asObject(rt).asArray(rt),
|
42
|
+
count <= 2 ? throw jsi::JSError(rt, "Expected argument in position 2 to be passed") : args[2].asBool()
|
42
43
|
);
|
43
44
|
}
|
44
45
|
static jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getSubscriptionGroups(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
45
46
|
return static_cast<NativeMobilyflowReactNativeSdkCxxSpecJSI *>(&turboModule)->getSubscriptionGroups(
|
46
47
|
rt,
|
47
48
|
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
48
|
-
count <= 1
|
49
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asObject(rt).asArray(rt),
|
50
|
+
count <= 2 ? throw jsi::JSError(rt, "Expected argument in position 2 to be passed") : args[2].asBool()
|
49
51
|
);
|
50
52
|
}
|
51
53
|
static jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getEntitlementForSubscription(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
@@ -109,14 +111,20 @@ static jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getSto
|
|
109
111
|
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
110
112
|
);
|
111
113
|
}
|
114
|
+
static jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_isForwardingEnable(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
115
|
+
return static_cast<NativeMobilyflowReactNativeSdkCxxSpecJSI *>(&turboModule)->isForwardingEnable(
|
116
|
+
rt,
|
117
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
118
|
+
);
|
119
|
+
}
|
112
120
|
|
113
121
|
NativeMobilyflowReactNativeSdkCxxSpecJSI::NativeMobilyflowReactNativeSdkCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
|
114
122
|
: TurboModule("MobilyflowReactNativeSdk", jsInvoker) {
|
115
123
|
methodMap_["instantiate"] = MethodMetadata {4, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_instantiate};
|
116
124
|
methodMap_["close"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_close};
|
117
125
|
methodMap_["login"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_login};
|
118
|
-
methodMap_["getProducts"] = MethodMetadata {
|
119
|
-
methodMap_["getSubscriptionGroups"] = MethodMetadata {
|
126
|
+
methodMap_["getProducts"] = MethodMetadata {3, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getProducts};
|
127
|
+
methodMap_["getSubscriptionGroups"] = MethodMetadata {3, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getSubscriptionGroups};
|
120
128
|
methodMap_["getEntitlementForSubscription"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getEntitlementForSubscription};
|
121
129
|
methodMap_["getEntitlement"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getEntitlement};
|
122
130
|
methodMap_["getEntitlements"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getEntitlements};
|
@@ -126,6 +134,7 @@ NativeMobilyflowReactNativeSdkCxxSpecJSI::NativeMobilyflowReactNativeSdkCxxSpecJ
|
|
126
134
|
methodMap_["purchaseProduct"] = MethodMetadata {3, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_purchaseProduct};
|
127
135
|
methodMap_["sendDiagnotic"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_sendDiagnotic};
|
128
136
|
methodMap_["getStoreCountry"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getStoreCountry};
|
137
|
+
methodMap_["isForwardingEnable"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_isForwardingEnable};
|
129
138
|
}
|
130
139
|
|
131
140
|
|
@@ -131,8 +131,8 @@ public:
|
|
131
131
|
virtual jsi::String instantiate(jsi::Runtime &rt, jsi::String appId, jsi::String apiKey, double environment, std::optional<jsi::Object> options) = 0;
|
132
132
|
virtual void close(jsi::Runtime &rt, jsi::String uuid) = 0;
|
133
133
|
virtual jsi::Value login(jsi::Runtime &rt, jsi::String uuid, jsi::String externalId) = 0;
|
134
|
-
virtual jsi::Value getProducts(jsi::Runtime &rt, jsi::String uuid,
|
135
|
-
virtual jsi::Value getSubscriptionGroups(jsi::Runtime &rt, jsi::String uuid,
|
134
|
+
virtual jsi::Value getProducts(jsi::Runtime &rt, jsi::String uuid, jsi::Array identifiers, bool onlyAvailable) = 0;
|
135
|
+
virtual jsi::Value getSubscriptionGroups(jsi::Runtime &rt, jsi::String uuid, jsi::Array identifiers, bool onlyAvailable) = 0;
|
136
136
|
virtual jsi::Value getEntitlementForSubscription(jsi::Runtime &rt, jsi::String uuid, jsi::String subscriptionGroupId) = 0;
|
137
137
|
virtual jsi::Value getEntitlement(jsi::Runtime &rt, jsi::String uuid, jsi::String productId) = 0;
|
138
138
|
virtual jsi::Value getEntitlements(jsi::Runtime &rt, jsi::String uuid, jsi::Array productIds) = 0;
|
@@ -142,6 +142,7 @@ public:
|
|
142
142
|
virtual jsi::Value purchaseProduct(jsi::Runtime &rt, jsi::String uuid, jsi::String productId, std::optional<jsi::Object> options) = 0;
|
143
143
|
virtual void sendDiagnotic(jsi::Runtime &rt, jsi::String uuid) = 0;
|
144
144
|
virtual jsi::Value getStoreCountry(jsi::Runtime &rt, jsi::String uuid) = 0;
|
145
|
+
virtual jsi::Value isForwardingEnable(jsi::Runtime &rt, jsi::String uuid) = 0;
|
145
146
|
|
146
147
|
};
|
147
148
|
|
@@ -196,21 +197,21 @@ private:
|
|
196
197
|
return bridging::callFromJs<jsi::Value>(
|
197
198
|
rt, &T::login, jsInvoker_, instance_, std::move(uuid), std::move(externalId));
|
198
199
|
}
|
199
|
-
jsi::Value getProducts(jsi::Runtime &rt, jsi::String uuid,
|
200
|
+
jsi::Value getProducts(jsi::Runtime &rt, jsi::String uuid, jsi::Array identifiers, bool onlyAvailable) override {
|
200
201
|
static_assert(
|
201
|
-
bridging::getParameterCount(&T::getProducts) ==
|
202
|
-
"Expected getProducts(...) to have
|
202
|
+
bridging::getParameterCount(&T::getProducts) == 4,
|
203
|
+
"Expected getProducts(...) to have 4 parameters");
|
203
204
|
|
204
205
|
return bridging::callFromJs<jsi::Value>(
|
205
|
-
rt, &T::getProducts, jsInvoker_, instance_, std::move(uuid), std::move(identifiers));
|
206
|
+
rt, &T::getProducts, jsInvoker_, instance_, std::move(uuid), std::move(identifiers), std::move(onlyAvailable));
|
206
207
|
}
|
207
|
-
jsi::Value getSubscriptionGroups(jsi::Runtime &rt, jsi::String uuid,
|
208
|
+
jsi::Value getSubscriptionGroups(jsi::Runtime &rt, jsi::String uuid, jsi::Array identifiers, bool onlyAvailable) override {
|
208
209
|
static_assert(
|
209
|
-
bridging::getParameterCount(&T::getSubscriptionGroups) ==
|
210
|
-
"Expected getSubscriptionGroups(...) to have
|
210
|
+
bridging::getParameterCount(&T::getSubscriptionGroups) == 4,
|
211
|
+
"Expected getSubscriptionGroups(...) to have 4 parameters");
|
211
212
|
|
212
213
|
return bridging::callFromJs<jsi::Value>(
|
213
|
-
rt, &T::getSubscriptionGroups, jsInvoker_, instance_, std::move(uuid), std::move(identifiers));
|
214
|
+
rt, &T::getSubscriptionGroups, jsInvoker_, instance_, std::move(uuid), std::move(identifiers), std::move(onlyAvailable));
|
214
215
|
}
|
215
216
|
jsi::Value getEntitlementForSubscription(jsi::Runtime &rt, jsi::String uuid, jsi::String subscriptionGroupId) override {
|
216
217
|
static_assert(
|
@@ -284,6 +285,14 @@ private:
|
|
284
285
|
return bridging::callFromJs<jsi::Value>(
|
285
286
|
rt, &T::getStoreCountry, jsInvoker_, instance_, std::move(uuid));
|
286
287
|
}
|
288
|
+
jsi::Value isForwardingEnable(jsi::Runtime &rt, jsi::String uuid) override {
|
289
|
+
static_assert(
|
290
|
+
bridging::getParameterCount(&T::isForwardingEnable) == 2,
|
291
|
+
"Expected isForwardingEnable(...) to have 2 parameters");
|
292
|
+
|
293
|
+
return bridging::callFromJs<jsi::Value>(
|
294
|
+
rt, &T::isForwardingEnable, jsInvoker_, instance_, std::move(uuid));
|
295
|
+
}
|
287
296
|
|
288
297
|
private:
|
289
298
|
friend class NativeMobilyflowReactNativeSdkCxxSpec;
|
package/android/src/main/java/com/mobilyflowreactnativesdk/MobilyflowReactNativeSdkModule.kt
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
package com.mobilyflowreactnativesdk
|
2
2
|
|
3
|
-
import android.util.Log
|
4
3
|
import com.facebook.react.bridge.Promise
|
5
4
|
import com.facebook.react.bridge.ReactApplicationContext
|
6
5
|
import com.facebook.react.bridge.ReadableArray
|
@@ -64,18 +63,18 @@ class MobilyflowReactNativeSdkModule(reactContext: ReactApplicationContext) : Na
|
|
64
63
|
}
|
65
64
|
}
|
66
65
|
|
67
|
-
override fun getProducts(uuid: String, identifiers: ReadableArray?, promise: Promise) {
|
66
|
+
override fun getProducts(uuid: String, identifiers: ReadableArray?, onlyAvailable: Boolean, promise: Promise) {
|
68
67
|
try {
|
69
|
-
val products = _sdkInstances[uuid]!!.getProducts(identifiers.toStringArray(),
|
68
|
+
val products = _sdkInstances[uuid]!!.getProducts(identifiers.toStringArray(), onlyAvailable)
|
70
69
|
promise.resolve(products.toReadableArray())
|
71
70
|
} catch (error: Exception) {
|
72
71
|
throwError(error, promise)
|
73
72
|
}
|
74
73
|
}
|
75
74
|
|
76
|
-
override fun getSubscriptionGroups(uuid: String, identifiers: ReadableArray?, promise: Promise) {
|
75
|
+
override fun getSubscriptionGroups(uuid: String, identifiers: ReadableArray?, onlyAvailable: Boolean, promise: Promise) {
|
77
76
|
try {
|
78
|
-
val groups = _sdkInstances[uuid]!!.getSubscriptionGroups(identifiers.toStringArray(),
|
77
|
+
val groups = _sdkInstances[uuid]!!.getSubscriptionGroups(identifiers.toStringArray(), onlyAvailable)
|
79
78
|
promise.resolve(groups.toReadableArray())
|
80
79
|
} catch (error: Exception) {
|
81
80
|
throwError(error, promise)
|
@@ -160,7 +159,7 @@ class MobilyflowReactNativeSdkModule(reactContext: ReactApplicationContext) : Na
|
|
160
159
|
}
|
161
160
|
}
|
162
161
|
|
163
|
-
|
162
|
+
val status = sdk.purchaseProduct(reactApplicationContext.currentActivity!!, product, purchaseOptions)
|
164
163
|
promise.resolve(status.value)
|
165
164
|
} catch (error: Exception) {
|
166
165
|
throwError(error, promise)
|
@@ -175,6 +174,10 @@ class MobilyflowReactNativeSdkModule(reactContext: ReactApplicationContext) : Na
|
|
175
174
|
promise.reject("-1", "Not implemented")
|
176
175
|
}
|
177
176
|
|
177
|
+
override fun isForwardingEnable(uuid: String, promise: Promise) {
|
178
|
+
promise.resolve(_sdkInstances[uuid]!!.isForwardingEnable())
|
179
|
+
}
|
180
|
+
|
178
181
|
companion object {
|
179
182
|
const val NAME = "MobilyflowReactNativeSdk"
|
180
183
|
}
|
@@ -32,12 +32,12 @@ RCT_EXPORT_MODULE()
|
|
32
32
|
}
|
33
33
|
|
34
34
|
- (NSString *)instantiate:(NSString *)appId apiKey:(NSString *)apiKey environment:(double)environment options:(JS::NativeMobilyflowReactNativeSdk::MobilyPurchaseSDKOptions &)options {
|
35
|
-
|
35
|
+
|
36
36
|
NSString* uuid = [[NSUUID UUID] UUIDString];
|
37
|
-
|
37
|
+
|
38
38
|
MobilyPurchaseSDK *sdk = [[MobilyPurchaseSDK alloc] initWithAppId:appId apiKey:apiKey environment:(MobilyEnvironment) environment options:[ParserMobilyPurchaseSDKOptions parseFromJSI:options]];
|
39
39
|
[_sdkInstances setObject:sdk forKey:uuid];
|
40
|
-
|
40
|
+
|
41
41
|
return uuid;
|
42
42
|
}
|
43
43
|
|
@@ -55,8 +55,8 @@ RCT_EXPORT_MODULE()
|
|
55
55
|
}];
|
56
56
|
}
|
57
57
|
|
58
|
-
- (void)getProducts:(NSString *)uuid identifiers:(NSArray *)identifiers resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
59
|
-
[[self getInstance:uuid] getProductsWithIdentifiers:identifiers completionHandler:^(NSArray<MobilyProduct *> * _Nullable products, NSError * _Nullable error) {
|
58
|
+
- (void)getProducts:(NSString *)uuid identifiers:(NSArray *)identifiers onlyAvailable:(BOOL)onlyAvailable resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
59
|
+
[[self getInstance:uuid] getProductsWithIdentifiers:identifiers onlyAvailable:onlyAvailable completionHandler:^(NSArray<MobilyProduct *> * _Nullable products, NSError * _Nullable error) {
|
60
60
|
if (error) {
|
61
61
|
reject([NSString stringWithFormat:@"%ld", error.code], error.description, error);
|
62
62
|
} else {
|
@@ -67,9 +67,9 @@ RCT_EXPORT_MODULE()
|
|
67
67
|
}];
|
68
68
|
}
|
69
69
|
|
70
|
-
- (void)getSubscriptionGroups:(NSString *)uuid identifiers:(NSArray *)identifiers resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
71
|
-
|
72
|
-
[[self getInstance:uuid] getSubscriptionGroupsWithIdentifiers:identifiers completionHandler:^(NSArray<MobilySubscriptionGroup *> * _Nullable groups, NSError * _Nullable error) {
|
70
|
+
- (void)getSubscriptionGroups:(NSString *)uuid identifiers:(NSArray *)identifiers onlyAvailable:(BOOL)onlyAvailable resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
71
|
+
|
72
|
+
[[self getInstance:uuid] getSubscriptionGroupsWithIdentifiers:identifiers onlyAvailable:onlyAvailable completionHandler:^(NSArray<MobilySubscriptionGroup *> * _Nullable groups, NSError * _Nullable error) {
|
73
73
|
if (error) {
|
74
74
|
reject([NSString stringWithFormat:@"%ld", error.code], error.description, error);
|
75
75
|
} else {
|
@@ -81,7 +81,7 @@ RCT_EXPORT_MODULE()
|
|
81
81
|
}
|
82
82
|
|
83
83
|
- (void)getEntitlementForSubscription:(NSString *)uuid subscriptionGroupId:(NSString *)subscriptionGroupId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
84
|
-
|
84
|
+
|
85
85
|
[[self getInstance:uuid] getEntitlementForSubscriptionWithSubscriptionGroupId:subscriptionGroupId completionHandler:^(MobilyCustomerEntitlement * _Nullable entitlement, NSError * _Nullable error) {
|
86
86
|
if (error) {
|
87
87
|
reject([NSString stringWithFormat:@"%ld", error.code], error.description, error);
|
@@ -92,7 +92,7 @@ RCT_EXPORT_MODULE()
|
|
92
92
|
}
|
93
93
|
|
94
94
|
- (void)getEntitlement:(NSString *)uuid productId:(NSString *)productId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
95
|
-
|
95
|
+
|
96
96
|
[[self getInstance:uuid] getEntitlementWithProductId:productId completionHandler:^(MobilyCustomerEntitlement * _Nullable entitlement, NSError * _Nullable error) {
|
97
97
|
if (error) {
|
98
98
|
reject([NSString stringWithFormat:@"%ld", error.code], error.description, error);
|
@@ -103,7 +103,7 @@ RCT_EXPORT_MODULE()
|
|
103
103
|
}
|
104
104
|
|
105
105
|
- (void)getEntitlements:(NSString *)uuid productIds:(NSArray *)productIds resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
106
|
-
|
106
|
+
|
107
107
|
[[self getInstance:uuid] getEntitlementsWithProductIds:productIds completionHandler:^(NSArray<MobilyCustomerEntitlement *> * _Nullable entitlements, NSError * _Nullable error) {
|
108
108
|
if (error) {
|
109
109
|
reject([NSString stringWithFormat:@"%ld", error.code], error.description, error);
|
@@ -116,7 +116,7 @@ RCT_EXPORT_MODULE()
|
|
116
116
|
}
|
117
117
|
|
118
118
|
- (void)requestTransferOwnership:(NSString *)uuid resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
119
|
-
|
119
|
+
|
120
120
|
[[self getInstance:uuid] requestTransferOwnershipWithCompletionHandler:^(enum TransferOwnershipStatus status, NSError * _Nullable error) {
|
121
121
|
if (error) {
|
122
122
|
reject([NSString stringWithFormat:@"%ld", error.code], error.description, error);
|
@@ -127,28 +127,28 @@ RCT_EXPORT_MODULE()
|
|
127
127
|
}
|
128
128
|
|
129
129
|
- (void)openManageSubscription:(NSString *)uuid resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
130
|
-
|
130
|
+
|
131
131
|
[[self getInstance:uuid] openManageSubscriptionWithCompletionHandler:^{
|
132
132
|
resolve([NSNumber numberWithInt:1]);
|
133
133
|
}];
|
134
134
|
}
|
135
135
|
|
136
136
|
- (void)openRefundDialog:(NSString *)uuid transactionId:(NSString *)transactionId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
137
|
-
|
137
|
+
|
138
138
|
[[self getInstance:uuid] openRefundDialogWithTransactionId:[transactionId longLongValue] completionHandler:^(BOOL result) {
|
139
139
|
resolve([NSNumber numberWithBool:result]);
|
140
140
|
}];
|
141
141
|
}
|
142
142
|
|
143
143
|
- (void)purchaseProduct:(NSString *)uuid productId:(NSString *)productId options:(JS::NativeMobilyflowReactNativeSdk::PurchaseOptions &)options resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
144
|
-
|
144
|
+
|
145
145
|
MobilyPurchaseSDK* sdk = [self getInstance:uuid];
|
146
|
-
|
146
|
+
|
147
147
|
NSString *offerId = options.offerId();
|
148
148
|
int quantity = (int)options.quantity();
|
149
|
-
|
149
|
+
|
150
150
|
[sdk getProductsWithIdentifiers:nil completionHandler:^(NSArray<MobilyProduct *> * _Nullable products, NSError * _Nullable error) {
|
151
|
-
|
151
|
+
|
152
152
|
if (error) {
|
153
153
|
reject([NSString stringWithFormat:@"%ld", error.code], error.description, error);
|
154
154
|
} else {
|
@@ -156,13 +156,13 @@ RCT_EXPORT_MODULE()
|
|
156
156
|
if (quantity > 1) {
|
157
157
|
purchaseOptions = [purchaseOptions setQuantity:quantity];
|
158
158
|
}
|
159
|
-
|
159
|
+
|
160
160
|
MobilyProduct *product = nil;
|
161
|
-
|
161
|
+
|
162
162
|
for (MobilyProduct *it in products) {
|
163
163
|
if ([it.id isEqualToString:productId]) {
|
164
164
|
product = it;
|
165
|
-
|
165
|
+
|
166
166
|
if (offerId != nil) {
|
167
167
|
if ([it.subscriptionProduct.baseOffer.id isEqualToString:offerId]) {
|
168
168
|
purchaseOptions = [purchaseOptions setOffer:it.subscriptionProduct.baseOffer];
|
@@ -177,16 +177,16 @@ RCT_EXPORT_MODULE()
|
|
177
177
|
}
|
178
178
|
}
|
179
179
|
}
|
180
|
-
|
180
|
+
|
181
181
|
break;
|
182
182
|
}
|
183
183
|
}
|
184
|
-
|
184
|
+
|
185
185
|
if (product == nil) {
|
186
186
|
reject(@"-1", [NSString stringWithFormat:@"Unknown productId (%@)", productId], nil);
|
187
187
|
return;
|
188
188
|
}
|
189
|
-
|
189
|
+
|
190
190
|
[sdk purchaseProduct:product options:purchaseOptions completionHandler:^(enum WebhookStatus status, NSError * _Nullable error) {
|
191
191
|
if (error) {
|
192
192
|
reject([NSString stringWithFormat:@"%ld", error.code], error.description, error);
|
@@ -208,4 +208,10 @@ RCT_EXPORT_MODULE()
|
|
208
208
|
}];
|
209
209
|
}
|
210
210
|
|
211
|
+
- (void)isForwardingEnable:(NSString *)uuid resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
212
|
+
[[self getInstance:uuid] isForwardingEnableWithCompletionHandler:^(BOOL result, NSError * _Nullable error) {
|
213
|
+
resolve([NSNumber numberWithBool:result]);
|
214
|
+
}];
|
215
|
+
}
|
216
|
+
|
211
217
|
@end
|
package/ios/generated/RNMobilyflowReactNativeSdkSpec/RNMobilyflowReactNativeSdkSpec-generated.mm
CHANGED
@@ -50,11 +50,11 @@ namespace facebook::react {
|
|
50
50
|
}
|
51
51
|
|
52
52
|
static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getProducts(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
53
|
-
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "getProducts", @selector(getProducts:identifiers:resolve:reject:), args, count);
|
53
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "getProducts", @selector(getProducts:identifiers:onlyAvailable:resolve:reject:), args, count);
|
54
54
|
}
|
55
55
|
|
56
56
|
static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getSubscriptionGroups(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
57
|
-
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "getSubscriptionGroups", @selector(getSubscriptionGroups:identifiers:resolve:reject:), args, count);
|
57
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "getSubscriptionGroups", @selector(getSubscriptionGroups:identifiers:onlyAvailable:resolve:reject:), args, count);
|
58
58
|
}
|
59
59
|
|
60
60
|
static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getEntitlementForSubscription(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
@@ -93,6 +93,10 @@ namespace facebook::react {
|
|
93
93
|
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "getStoreCountry", @selector(getStoreCountry:resolve:reject:), args, count);
|
94
94
|
}
|
95
95
|
|
96
|
+
static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_isForwardingEnable(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
97
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "isForwardingEnable", @selector(isForwardingEnable:resolve:reject:), args, count);
|
98
|
+
}
|
99
|
+
|
96
100
|
NativeMobilyflowReactNativeSdkSpecJSI::NativeMobilyflowReactNativeSdkSpecJSI(const ObjCTurboModule::InitParams ¶ms)
|
97
101
|
: ObjCTurboModule(params) {
|
98
102
|
|
@@ -105,10 +109,10 @@ namespace facebook::react {
|
|
105
109
|
methodMap_["login"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_login};
|
106
110
|
|
107
111
|
|
108
|
-
methodMap_["getProducts"] = MethodMetadata {
|
112
|
+
methodMap_["getProducts"] = MethodMetadata {3, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getProducts};
|
109
113
|
|
110
114
|
|
111
|
-
methodMap_["getSubscriptionGroups"] = MethodMetadata {
|
115
|
+
methodMap_["getSubscriptionGroups"] = MethodMetadata {3, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getSubscriptionGroups};
|
112
116
|
|
113
117
|
|
114
118
|
methodMap_["getEntitlementForSubscription"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getEntitlementForSubscription};
|
@@ -137,5 +141,8 @@ namespace facebook::react {
|
|
137
141
|
|
138
142
|
methodMap_["getStoreCountry"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getStoreCountry};
|
139
143
|
|
144
|
+
|
145
|
+
methodMap_["isForwardingEnable"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_isForwardingEnable};
|
146
|
+
|
140
147
|
}
|
141
148
|
} // namespace facebook::react
|
@@ -78,10 +78,12 @@ namespace JS {
|
|
78
78
|
reject:(RCTPromiseRejectBlock)reject;
|
79
79
|
- (void)getProducts:(NSString *)uuid
|
80
80
|
identifiers:(NSArray *)identifiers
|
81
|
+
onlyAvailable:(BOOL)onlyAvailable
|
81
82
|
resolve:(RCTPromiseResolveBlock)resolve
|
82
83
|
reject:(RCTPromiseRejectBlock)reject;
|
83
84
|
- (void)getSubscriptionGroups:(NSString *)uuid
|
84
85
|
identifiers:(NSArray *)identifiers
|
86
|
+
onlyAvailable:(BOOL)onlyAvailable
|
85
87
|
resolve:(RCTPromiseResolveBlock)resolve
|
86
88
|
reject:(RCTPromiseRejectBlock)reject;
|
87
89
|
- (void)getEntitlementForSubscription:(NSString *)uuid
|
@@ -115,6 +117,9 @@ namespace JS {
|
|
115
117
|
- (void)getStoreCountry:(NSString *)uuid
|
116
118
|
resolve:(RCTPromiseResolveBlock)resolve
|
117
119
|
reject:(RCTPromiseRejectBlock)reject;
|
120
|
+
- (void)isForwardingEnable:(NSString *)uuid
|
121
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
122
|
+
reject:(RCTPromiseRejectBlock)reject;
|
118
123
|
|
119
124
|
@end
|
120
125
|
|
@@ -38,14 +38,16 @@ static jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getPro
|
|
38
38
|
return static_cast<NativeMobilyflowReactNativeSdkCxxSpecJSI *>(&turboModule)->getProducts(
|
39
39
|
rt,
|
40
40
|
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
41
|
-
count <= 1
|
41
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asObject(rt).asArray(rt),
|
42
|
+
count <= 2 ? throw jsi::JSError(rt, "Expected argument in position 2 to be passed") : args[2].asBool()
|
42
43
|
);
|
43
44
|
}
|
44
45
|
static jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getSubscriptionGroups(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
45
46
|
return static_cast<NativeMobilyflowReactNativeSdkCxxSpecJSI *>(&turboModule)->getSubscriptionGroups(
|
46
47
|
rt,
|
47
48
|
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
|
48
|
-
count <= 1
|
49
|
+
count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asObject(rt).asArray(rt),
|
50
|
+
count <= 2 ? throw jsi::JSError(rt, "Expected argument in position 2 to be passed") : args[2].asBool()
|
49
51
|
);
|
50
52
|
}
|
51
53
|
static jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getEntitlementForSubscription(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
@@ -109,14 +111,20 @@ static jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getSto
|
|
109
111
|
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
110
112
|
);
|
111
113
|
}
|
114
|
+
static jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_isForwardingEnable(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
115
|
+
return static_cast<NativeMobilyflowReactNativeSdkCxxSpecJSI *>(&turboModule)->isForwardingEnable(
|
116
|
+
rt,
|
117
|
+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt)
|
118
|
+
);
|
119
|
+
}
|
112
120
|
|
113
121
|
NativeMobilyflowReactNativeSdkCxxSpecJSI::NativeMobilyflowReactNativeSdkCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
|
114
122
|
: TurboModule("MobilyflowReactNativeSdk", jsInvoker) {
|
115
123
|
methodMap_["instantiate"] = MethodMetadata {4, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_instantiate};
|
116
124
|
methodMap_["close"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_close};
|
117
125
|
methodMap_["login"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_login};
|
118
|
-
methodMap_["getProducts"] = MethodMetadata {
|
119
|
-
methodMap_["getSubscriptionGroups"] = MethodMetadata {
|
126
|
+
methodMap_["getProducts"] = MethodMetadata {3, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getProducts};
|
127
|
+
methodMap_["getSubscriptionGroups"] = MethodMetadata {3, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getSubscriptionGroups};
|
120
128
|
methodMap_["getEntitlementForSubscription"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getEntitlementForSubscription};
|
121
129
|
methodMap_["getEntitlement"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getEntitlement};
|
122
130
|
methodMap_["getEntitlements"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getEntitlements};
|
@@ -126,6 +134,7 @@ NativeMobilyflowReactNativeSdkCxxSpecJSI::NativeMobilyflowReactNativeSdkCxxSpecJ
|
|
126
134
|
methodMap_["purchaseProduct"] = MethodMetadata {3, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_purchaseProduct};
|
127
135
|
methodMap_["sendDiagnotic"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_sendDiagnotic};
|
128
136
|
methodMap_["getStoreCountry"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_getStoreCountry};
|
137
|
+
methodMap_["isForwardingEnable"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkCxxSpecJSI_isForwardingEnable};
|
129
138
|
}
|
130
139
|
|
131
140
|
|
@@ -131,8 +131,8 @@ public:
|
|
131
131
|
virtual jsi::String instantiate(jsi::Runtime &rt, jsi::String appId, jsi::String apiKey, double environment, std::optional<jsi::Object> options) = 0;
|
132
132
|
virtual void close(jsi::Runtime &rt, jsi::String uuid) = 0;
|
133
133
|
virtual jsi::Value login(jsi::Runtime &rt, jsi::String uuid, jsi::String externalId) = 0;
|
134
|
-
virtual jsi::Value getProducts(jsi::Runtime &rt, jsi::String uuid,
|
135
|
-
virtual jsi::Value getSubscriptionGroups(jsi::Runtime &rt, jsi::String uuid,
|
134
|
+
virtual jsi::Value getProducts(jsi::Runtime &rt, jsi::String uuid, jsi::Array identifiers, bool onlyAvailable) = 0;
|
135
|
+
virtual jsi::Value getSubscriptionGroups(jsi::Runtime &rt, jsi::String uuid, jsi::Array identifiers, bool onlyAvailable) = 0;
|
136
136
|
virtual jsi::Value getEntitlementForSubscription(jsi::Runtime &rt, jsi::String uuid, jsi::String subscriptionGroupId) = 0;
|
137
137
|
virtual jsi::Value getEntitlement(jsi::Runtime &rt, jsi::String uuid, jsi::String productId) = 0;
|
138
138
|
virtual jsi::Value getEntitlements(jsi::Runtime &rt, jsi::String uuid, jsi::Array productIds) = 0;
|
@@ -142,6 +142,7 @@ public:
|
|
142
142
|
virtual jsi::Value purchaseProduct(jsi::Runtime &rt, jsi::String uuid, jsi::String productId, std::optional<jsi::Object> options) = 0;
|
143
143
|
virtual void sendDiagnotic(jsi::Runtime &rt, jsi::String uuid) = 0;
|
144
144
|
virtual jsi::Value getStoreCountry(jsi::Runtime &rt, jsi::String uuid) = 0;
|
145
|
+
virtual jsi::Value isForwardingEnable(jsi::Runtime &rt, jsi::String uuid) = 0;
|
145
146
|
|
146
147
|
};
|
147
148
|
|
@@ -196,21 +197,21 @@ private:
|
|
196
197
|
return bridging::callFromJs<jsi::Value>(
|
197
198
|
rt, &T::login, jsInvoker_, instance_, std::move(uuid), std::move(externalId));
|
198
199
|
}
|
199
|
-
jsi::Value getProducts(jsi::Runtime &rt, jsi::String uuid,
|
200
|
+
jsi::Value getProducts(jsi::Runtime &rt, jsi::String uuid, jsi::Array identifiers, bool onlyAvailable) override {
|
200
201
|
static_assert(
|
201
|
-
bridging::getParameterCount(&T::getProducts) ==
|
202
|
-
"Expected getProducts(...) to have
|
202
|
+
bridging::getParameterCount(&T::getProducts) == 4,
|
203
|
+
"Expected getProducts(...) to have 4 parameters");
|
203
204
|
|
204
205
|
return bridging::callFromJs<jsi::Value>(
|
205
|
-
rt, &T::getProducts, jsInvoker_, instance_, std::move(uuid), std::move(identifiers));
|
206
|
+
rt, &T::getProducts, jsInvoker_, instance_, std::move(uuid), std::move(identifiers), std::move(onlyAvailable));
|
206
207
|
}
|
207
|
-
jsi::Value getSubscriptionGroups(jsi::Runtime &rt, jsi::String uuid,
|
208
|
+
jsi::Value getSubscriptionGroups(jsi::Runtime &rt, jsi::String uuid, jsi::Array identifiers, bool onlyAvailable) override {
|
208
209
|
static_assert(
|
209
|
-
bridging::getParameterCount(&T::getSubscriptionGroups) ==
|
210
|
-
"Expected getSubscriptionGroups(...) to have
|
210
|
+
bridging::getParameterCount(&T::getSubscriptionGroups) == 4,
|
211
|
+
"Expected getSubscriptionGroups(...) to have 4 parameters");
|
211
212
|
|
212
213
|
return bridging::callFromJs<jsi::Value>(
|
213
|
-
rt, &T::getSubscriptionGroups, jsInvoker_, instance_, std::move(uuid), std::move(identifiers));
|
214
|
+
rt, &T::getSubscriptionGroups, jsInvoker_, instance_, std::move(uuid), std::move(identifiers), std::move(onlyAvailable));
|
214
215
|
}
|
215
216
|
jsi::Value getEntitlementForSubscription(jsi::Runtime &rt, jsi::String uuid, jsi::String subscriptionGroupId) override {
|
216
217
|
static_assert(
|
@@ -284,6 +285,14 @@ private:
|
|
284
285
|
return bridging::callFromJs<jsi::Value>(
|
285
286
|
rt, &T::getStoreCountry, jsInvoker_, instance_, std::move(uuid));
|
286
287
|
}
|
288
|
+
jsi::Value isForwardingEnable(jsi::Runtime &rt, jsi::String uuid) override {
|
289
|
+
static_assert(
|
290
|
+
bridging::getParameterCount(&T::isForwardingEnable) == 2,
|
291
|
+
"Expected isForwardingEnable(...) to have 2 parameters");
|
292
|
+
|
293
|
+
return bridging::callFromJs<jsi::Value>(
|
294
|
+
rt, &T::isForwardingEnable, jsInvoker_, instance_, std::move(uuid));
|
295
|
+
}
|
287
296
|
|
288
297
|
private:
|
289
298
|
friend class NativeMobilyflowReactNativeSdkCxxSpec;
|
package/package.json
CHANGED
@@ -21,8 +21,12 @@ export interface Spec extends TurboModule {
|
|
21
21
|
close(uuid: string): void;
|
22
22
|
|
23
23
|
login(uuid: string, externalId: string): Promise<void>;
|
24
|
-
getProducts(uuid: string, identifiers
|
25
|
-
getSubscriptionGroups(
|
24
|
+
getProducts(uuid: string, identifiers: string[], onlyAvailable: boolean): Promise<MobilyProduct[]>;
|
25
|
+
getSubscriptionGroups(
|
26
|
+
uuid: string,
|
27
|
+
identifiers: string[],
|
28
|
+
onlyAvailable: boolean
|
29
|
+
): Promise<MobilySubscriptionGroup[]>;
|
26
30
|
|
27
31
|
getEntitlementForSubscription(uuid: string, subscriptionGroupId: string): Promise<MobilyCustomerEntitlement | null>;
|
28
32
|
getEntitlement(uuid: string, productId: string): Promise<MobilyCustomerEntitlement | null>;
|
@@ -36,6 +40,7 @@ export interface Spec extends TurboModule {
|
|
36
40
|
|
37
41
|
sendDiagnotic(uuid: string): void;
|
38
42
|
getStoreCountry(uuid: string): Promise<string>;
|
43
|
+
isForwardingEnable(uuid: string): Promise<boolean>;
|
39
44
|
}
|
40
45
|
|
41
46
|
export default TurboModuleRegistry.getEnforcing<Spec>('MobilyflowReactNativeSdk');
|
package/src/index.tsx
CHANGED
@@ -61,18 +61,18 @@ export class MobilyPurchaseSDK {
|
|
61
61
|
}
|
62
62
|
}
|
63
63
|
|
64
|
-
async getProducts(identifiers?: string[]) {
|
64
|
+
async getProducts(identifiers?: string[], onlyAvailable = false): Promise<MobilyProduct[]> {
|
65
65
|
try {
|
66
|
-
const products = await MobilyflowReactNativeSdk.getProducts(this._uuid, identifiers);
|
66
|
+
const products = await MobilyflowReactNativeSdk.getProducts(this._uuid, identifiers, onlyAvailable);
|
67
67
|
return products.map(MobilyProduct.parseFromAPI);
|
68
68
|
} catch (error: any) {
|
69
69
|
throw this.throwError(error);
|
70
70
|
}
|
71
71
|
}
|
72
72
|
|
73
|
-
async getSubscriptionGroups(identifiers?: string[]) {
|
73
|
+
async getSubscriptionGroups(identifiers?: string[], onlyAvailable = false) {
|
74
74
|
try {
|
75
|
-
const groups = await MobilyflowReactNativeSdk.getSubscriptionGroups(this._uuid, identifiers);
|
75
|
+
const groups = await MobilyflowReactNativeSdk.getSubscriptionGroups(this._uuid, identifiers, onlyAvailable);
|
76
76
|
return groups.map(MobilySubscriptionGroup.parseFromAPI);
|
77
77
|
} catch (error: any) {
|
78
78
|
throw this.throwError(error);
|
@@ -164,4 +164,12 @@ export class MobilyPurchaseSDK {
|
|
164
164
|
}
|
165
165
|
}
|
166
166
|
}
|
167
|
+
|
168
|
+
async isForwardingEnable() {
|
169
|
+
try {
|
170
|
+
return await MobilyflowReactNativeSdk.isForwardingEnable(this._uuid);
|
171
|
+
} catch (error: any) {
|
172
|
+
throw this.throwError(error);
|
173
|
+
}
|
174
|
+
}
|
167
175
|
}
|