mobilyflow-react-native-sdk 0.0.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/LICENSE +20 -0
- package/MobilyflowReactNativeSdk.podspec +52 -0
- package/README.md +33 -0
- package/android/build.gradle +114 -0
- package/android/generated/java/com/mobilyflowreactnativesdk/NativeMobilyflowReactNativeSdkSpec.java +89 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNMobilyflowReactNativeSdkSpec-generated.cpp +104 -0
- package/android/generated/jni/RNMobilyflowReactNativeSdkSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNMobilyflowReactNativeSdkSpec/RNMobilyflowReactNativeSdkSpecJSI-generated.cpp +124 -0
- package/android/generated/jni/react/renderer/components/RNMobilyflowReactNativeSdkSpec/RNMobilyflowReactNativeSdkSpecJSI.h +287 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/mobilyflowreactnativesdk/MobilyflowReactNativeSdkModule.kt +183 -0
- package/android/src/main/java/com/mobilyflowreactnativesdk/MobilyflowReactNativeSdkPackage.kt +32 -0
- package/android/src/main/java/com/mobilyflowreactnativesdk/ParserUtils.kt +149 -0
- package/ios/MobilyflowReactNativeSdk.h +7 -0
- package/ios/MobilyflowReactNativeSdk.mm +204 -0
- package/ios/Utils/ParserMobilyPurchaseSDKOptions.h +21 -0
- package/ios/Utils/ParserMobilyPurchaseSDKOptions.mm +25 -0
- package/ios/Utils/Utils.h +18 -0
- package/ios/Utils/Utils.m +22 -0
- package/ios/generated/RNMobilyflowReactNativeSdkSpec/RNMobilyflowReactNativeSdkSpec-generated.mm +134 -0
- package/ios/generated/RNMobilyflowReactNativeSdkSpec/RNMobilyflowReactNativeSdkSpec.h +161 -0
- package/ios/generated/RNMobilyflowReactNativeSdkSpecJSI-generated.cpp +124 -0
- package/ios/generated/RNMobilyflowReactNativeSdkSpecJSI.h +287 -0
- package/package.json +183 -0
- package/react-native.config.js +12 -0
- package/src/NativeMobilyflowReactNativeSdk.ts +46 -0
- package/src/entities/mobily-customer-entitlement.ts +37 -0
- package/src/entities/mobily-one-time-product.ts +11 -0
- package/src/entities/mobily-product.ts +34 -0
- package/src/entities/mobily-subscription-group.ts +20 -0
- package/src/entities/mobily-subscription-offer.ts +16 -0
- package/src/entities/mobily-subscription-product.ts +14 -0
- package/src/enums/mobily-environment.ts +5 -0
- package/src/enums/period-unit.ts +5 -0
- package/src/enums/platform.ts +4 -0
- package/src/enums/product-status.ts +5 -0
- package/src/enums/product-type.ts +4 -0
- package/src/enums/webhook-status.ts +5 -0
- package/src/errors/mobily-error.ts +18 -0
- package/src/errors/mobily-purchase-error.ts +30 -0
- package/src/errors/mobily-transfer-ownership-error.ts +20 -0
- package/src/index.tsx +153 -0
- package/src/utils/object-transformer.ts +60 -0
@@ -0,0 +1,204 @@
|
|
1
|
+
#import "MobilyflowReactNativeSdk.h"
|
2
|
+
#import <MobilyflowSDK/MobilyflowSDK.h>
|
3
|
+
#import <Foundation/NSUUID.h>
|
4
|
+
#import "Utils/ParserMobilyPurchaseSDKOptions.h"
|
5
|
+
#import "Utils/Utils.h"
|
6
|
+
|
7
|
+
@interface MobilyflowReactNativeSdk()
|
8
|
+
@property (strong, nonatomic) NSMutableDictionary* sdkInstances;
|
9
|
+
@end
|
10
|
+
|
11
|
+
@implementation MobilyflowReactNativeSdk
|
12
|
+
|
13
|
+
RCT_EXPORT_MODULE()
|
14
|
+
|
15
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
16
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
17
|
+
{
|
18
|
+
return std::make_shared<facebook::react::NativeMobilyflowReactNativeSdkSpecJSI>(params);
|
19
|
+
}
|
20
|
+
|
21
|
+
|
22
|
+
- (id) init {
|
23
|
+
if (self = [super init]) {
|
24
|
+
_sdkInstances = [NSMutableDictionary dictionary];
|
25
|
+
}
|
26
|
+
return self;
|
27
|
+
}
|
28
|
+
|
29
|
+
|
30
|
+
-(MobilyPurchaseSDK*)getInstance:(NSString*)uuid {
|
31
|
+
return [_sdkInstances objectForKey:uuid];
|
32
|
+
}
|
33
|
+
|
34
|
+
- (NSString *)instantiate:(NSString *)appId apiKey:(NSString *)apiKey environment:(double)environment options:(JS::NativeMobilyflowReactNativeSdk::MobilyPurchaseSDKOptions &)options {
|
35
|
+
|
36
|
+
NSString* uuid = [[NSUUID UUID] UUIDString];
|
37
|
+
|
38
|
+
MobilyPurchaseSDK *sdk = [[MobilyPurchaseSDK alloc] initWithAppId:appId apiKey:apiKey environment:(MobilyEnvironment) environment options:[ParserMobilyPurchaseSDKOptions parseFromJSI:options]];
|
39
|
+
[_sdkInstances setObject:sdk forKey:uuid];
|
40
|
+
|
41
|
+
return uuid;
|
42
|
+
}
|
43
|
+
|
44
|
+
- (void)close:(NSString *)uuid {
|
45
|
+
return [[self getInstance:uuid] close];
|
46
|
+
}
|
47
|
+
|
48
|
+
- (void)login:(NSString *)uuid externalId:(NSString *)externalId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
49
|
+
[[self getInstance:uuid] loginWithExternalId:externalId completionHandler:^(NSError * _Nullable error) {
|
50
|
+
if (error) {
|
51
|
+
reject([NSString stringWithFormat:@"%ld", error.code], error.description, error);
|
52
|
+
} else {
|
53
|
+
resolve(0);
|
54
|
+
}
|
55
|
+
}];
|
56
|
+
}
|
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) {
|
60
|
+
if (error) {
|
61
|
+
reject([NSString stringWithFormat:@"%ld", error.code], error.description, error);
|
62
|
+
} else {
|
63
|
+
resolve([Utils arrayMap:products withBlock:^id _Nonnull(Serializable* _Nonnull obj, NSUInteger idx) {
|
64
|
+
return [obj toDictionary];
|
65
|
+
}]);
|
66
|
+
}
|
67
|
+
}];
|
68
|
+
}
|
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) {
|
73
|
+
if (error) {
|
74
|
+
reject([NSString stringWithFormat:@"%ld", error.code], error.description, error);
|
75
|
+
} else {
|
76
|
+
resolve([Utils arrayMap:groups withBlock:^id _Nonnull(Serializable* _Nonnull obj, NSUInteger idx) {
|
77
|
+
return [obj toDictionary];
|
78
|
+
}]);
|
79
|
+
}
|
80
|
+
}];
|
81
|
+
}
|
82
|
+
|
83
|
+
- (void)getEntitlementForSubscription:(NSString *)uuid subscriptionGroupId:(NSString *)subscriptionGroupId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
84
|
+
|
85
|
+
[[self getInstance:uuid] getEntitlementForSubscriptionWithSubscriptionGroupId:subscriptionGroupId completionHandler:^(MobilyCustomerEntitlement * _Nullable entitlement, NSError * _Nullable error) {
|
86
|
+
if (error) {
|
87
|
+
reject([NSString stringWithFormat:@"%ld", error.code], error.description, error);
|
88
|
+
} else {
|
89
|
+
resolve([entitlement toDictionary]);
|
90
|
+
}
|
91
|
+
}];
|
92
|
+
}
|
93
|
+
|
94
|
+
- (void)getEntitlement:(NSString *)uuid productId:(NSString *)productId resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
95
|
+
|
96
|
+
[[self getInstance:uuid] getEntitlementWithProductId:productId completionHandler:^(MobilyCustomerEntitlement * _Nullable entitlement, NSError * _Nullable error) {
|
97
|
+
if (error) {
|
98
|
+
reject([NSString stringWithFormat:@"%ld", error.code], error.description, error);
|
99
|
+
} else {
|
100
|
+
resolve([entitlement toDictionary]);
|
101
|
+
}
|
102
|
+
}];
|
103
|
+
}
|
104
|
+
|
105
|
+
- (void)getEntitlements:(NSString *)uuid productIds:(NSArray *)productIds resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
106
|
+
|
107
|
+
[[self getInstance:uuid] getEntitlementsWithProductIds:productIds completionHandler:^(NSArray<MobilyCustomerEntitlement *> * _Nullable entitlements, NSError * _Nullable error) {
|
108
|
+
if (error) {
|
109
|
+
reject([NSString stringWithFormat:@"%ld", error.code], error.description, error);
|
110
|
+
} else {
|
111
|
+
resolve([Utils arrayMap:entitlements withBlock:^id _Nonnull(Serializable* _Nonnull obj, NSUInteger idx) {
|
112
|
+
return [obj toDictionary];
|
113
|
+
}]);
|
114
|
+
}
|
115
|
+
}];
|
116
|
+
}
|
117
|
+
|
118
|
+
- (void)requestTransferOwnership:(NSString *)uuid resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
119
|
+
|
120
|
+
[[self getInstance:uuid] requestTransferOwnershipWithCompletionHandler:^(enum TransferOwnershipStatus status, NSError * _Nullable error) {
|
121
|
+
if (error) {
|
122
|
+
reject([NSString stringWithFormat:@"%ld", error.code], error.description, error);
|
123
|
+
} else {
|
124
|
+
resolve([NSNumber numberWithInt:status]);
|
125
|
+
}
|
126
|
+
}];
|
127
|
+
}
|
128
|
+
|
129
|
+
- (void)openManageSubscription:(NSString *)uuid resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
130
|
+
|
131
|
+
[[self getInstance:uuid] openManageSubscriptionWithCompletionHandler:^{
|
132
|
+
resolve([NSNumber numberWithInt:1]);
|
133
|
+
}];
|
134
|
+
}
|
135
|
+
|
136
|
+
- (void)purchaseProduct:(NSString *)uuid productId:(NSString *)productId options:(JS::NativeMobilyflowReactNativeSdk::PurchaseOptions &)options resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
137
|
+
|
138
|
+
MobilyPurchaseSDK* sdk = [self getInstance:uuid];
|
139
|
+
|
140
|
+
NSString *offerId = options.offerId();
|
141
|
+
int quantity = (int)options.quantity();
|
142
|
+
|
143
|
+
[sdk getProductsWithIdentifiers:nil completionHandler:^(NSArray<MobilyProduct *> * _Nullable products, NSError * _Nullable error) {
|
144
|
+
|
145
|
+
if (error) {
|
146
|
+
reject([NSString stringWithFormat:@"%ld", error.code], error.description, error);
|
147
|
+
} else {
|
148
|
+
PurchaseOptions *purchaseOptions = [[PurchaseOptions alloc] init];
|
149
|
+
if (quantity > 1) {
|
150
|
+
purchaseOptions = [purchaseOptions setQuantity:quantity];
|
151
|
+
}
|
152
|
+
|
153
|
+
MobilyProduct *product = nil;
|
154
|
+
|
155
|
+
for (MobilyProduct *it in products) {
|
156
|
+
if ([it.id isEqualToString:productId]) {
|
157
|
+
product = it;
|
158
|
+
|
159
|
+
if (offerId != nil) {
|
160
|
+
if ([it.subscriptionProduct.baseOffer.id isEqualToString:offerId]) {
|
161
|
+
purchaseOptions = [purchaseOptions setOffer:it.subscriptionProduct.baseOffer];
|
162
|
+
} else if (it.subscriptionProduct.freeTrial != nil && [it.subscriptionProduct.freeTrial.id isEqualToString:offerId]) {
|
163
|
+
purchaseOptions = [purchaseOptions setOffer:it.subscriptionProduct.freeTrial];
|
164
|
+
} else {
|
165
|
+
for (MobilySubscriptionOffer *off in it.subscriptionProduct.promotionalOffers) {
|
166
|
+
if ([off.id isEqualToString:offerId]) {
|
167
|
+
purchaseOptions = [purchaseOptions setOffer:off];
|
168
|
+
break;
|
169
|
+
}
|
170
|
+
}
|
171
|
+
}
|
172
|
+
}
|
173
|
+
|
174
|
+
break;
|
175
|
+
}
|
176
|
+
}
|
177
|
+
|
178
|
+
if (product == nil) {
|
179
|
+
reject(@"-1", [NSString stringWithFormat:@"Unknown productId (%@)", productId], nil);
|
180
|
+
return;
|
181
|
+
}
|
182
|
+
|
183
|
+
[sdk purchaseProduct:product options:purchaseOptions completionHandler:^(enum WebhookStatus status, NSError * _Nullable error) {
|
184
|
+
if (error) {
|
185
|
+
reject([NSString stringWithFormat:@"%ld", error.code], error.description, error);
|
186
|
+
} else {
|
187
|
+
resolve([NSNumber numberWithInt:status]);
|
188
|
+
}
|
189
|
+
}];
|
190
|
+
}
|
191
|
+
}];
|
192
|
+
}
|
193
|
+
|
194
|
+
- (void)sendDiagnotic:(NSString *)uuid {
|
195
|
+
[[self getInstance:uuid] sendDiagnotic];
|
196
|
+
}
|
197
|
+
|
198
|
+
- (void)getStoreCountry:(NSString *)uuid resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
199
|
+
[[self getInstance:uuid] getStoreCountryWithCompletionHandler:^(NSString * _Nullable countryCode) {
|
200
|
+
resolve(countryCode);
|
201
|
+
}];
|
202
|
+
}
|
203
|
+
|
204
|
+
@end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
//
|
2
|
+
// ParserMobilyPurchaseSDKOptions.h
|
3
|
+
// MobilyflowReactNativeSdk
|
4
|
+
//
|
5
|
+
// Created by Gregoire Taja on 06/03/2025.
|
6
|
+
//
|
7
|
+
|
8
|
+
#import <Foundation/Foundation.h>
|
9
|
+
#import <RCTTypeSafety/RCTConvertHelpers.h>
|
10
|
+
#import "../generated/RNMobilyflowReactNativeSdkSpec/RNMobilyflowReactNativeSdkSpec.h"
|
11
|
+
#import <MobilyflowSDK/MobilyflowSDK.h>
|
12
|
+
|
13
|
+
NS_ASSUME_NONNULL_BEGIN
|
14
|
+
|
15
|
+
@interface ParserMobilyPurchaseSDKOptions : NSObject
|
16
|
+
|
17
|
+
+(MobilyPurchaseSDKOptions*)parseFromJSI:(JS::NativeMobilyflowReactNativeSdk::MobilyPurchaseSDKOptions &)jsi;
|
18
|
+
|
19
|
+
@end
|
20
|
+
|
21
|
+
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,25 @@
|
|
1
|
+
//
|
2
|
+
// ParserMobilyPurchaseSDKOptions.m
|
3
|
+
// MobilyflowReactNativeSdk
|
4
|
+
//
|
5
|
+
// Created by Gregoire Taja on 06/03/2025.
|
6
|
+
//
|
7
|
+
|
8
|
+
#import "ParserMobilyPurchaseSDKOptions.h"
|
9
|
+
|
10
|
+
@implementation ParserMobilyPurchaseSDKOptions
|
11
|
+
|
12
|
+
+(MobilyPurchaseSDKOptions*)parseFromJSI:(JS::NativeMobilyflowReactNativeSdk::MobilyPurchaseSDKOptions &)jsi {
|
13
|
+
NSArray<NSString*>* languages = nil;
|
14
|
+
if (jsi.languages().has_value()) {
|
15
|
+
languages = RCTConvertVecToArray(jsi.languages().value());
|
16
|
+
}
|
17
|
+
|
18
|
+
bool debug = jsi.debug().has_value() ? jsi.debug().value() : false;
|
19
|
+
|
20
|
+
NSString* apiURL = jsi.apiURL().length > 0 ? jsi.apiURL() : nil;
|
21
|
+
|
22
|
+
return [[MobilyPurchaseSDKOptions alloc] initWithLanguages:languages debug:debug apiURL:apiURL];
|
23
|
+
}
|
24
|
+
|
25
|
+
@end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
//
|
2
|
+
// Utils.h
|
3
|
+
// MobilyflowReactNativeSdk
|
4
|
+
//
|
5
|
+
// Created by Gregoire Taja on 18/03/2025.
|
6
|
+
//
|
7
|
+
|
8
|
+
#import <Foundation/Foundation.h>
|
9
|
+
|
10
|
+
NS_ASSUME_NONNULL_BEGIN
|
11
|
+
|
12
|
+
@interface Utils : NSObject
|
13
|
+
|
14
|
+
+(NSArray *)arrayMap:(NSArray*)array withBlock:(id (^)(id obj, NSUInteger idx))block;
|
15
|
+
|
16
|
+
@end
|
17
|
+
|
18
|
+
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,22 @@
|
|
1
|
+
//
|
2
|
+
// Utils.m
|
3
|
+
// MobilyflowReactNativeSdk
|
4
|
+
//
|
5
|
+
// Created by Gregoire Taja on 18/03/2025.
|
6
|
+
//
|
7
|
+
|
8
|
+
#import "Utils.h"
|
9
|
+
|
10
|
+
@implementation Utils
|
11
|
+
|
12
|
+
+(NSArray *)arrayMap:(NSArray*)array withBlock:(id (^)(id obj, NSUInteger idx))block {
|
13
|
+
NSMutableArray *result = [NSMutableArray arrayWithCapacity:[array count]];
|
14
|
+
|
15
|
+
[array enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
16
|
+
[result addObject:block(obj, idx)];
|
17
|
+
}];
|
18
|
+
|
19
|
+
return result;
|
20
|
+
}
|
21
|
+
|
22
|
+
@end
|
package/ios/generated/RNMobilyflowReactNativeSdkSpec/RNMobilyflowReactNativeSdkSpec-generated.mm
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
/**
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
3
|
+
*
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
5
|
+
* once the code is regenerated.
|
6
|
+
*
|
7
|
+
* @generated by codegen project: GenerateModuleObjCpp
|
8
|
+
*
|
9
|
+
* We create an umbrella header (and corresponding implementation) here since
|
10
|
+
* Cxx compilation in BUCK has a limitation: source-code producing genrule()s
|
11
|
+
* must have a single output. More files => more genrule()s => slower builds.
|
12
|
+
*/
|
13
|
+
|
14
|
+
#import "RNMobilyflowReactNativeSdkSpec.h"
|
15
|
+
|
16
|
+
|
17
|
+
@implementation NativeMobilyflowReactNativeSdkSpecBase
|
18
|
+
|
19
|
+
|
20
|
+
- (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *)eventEmitterCallbackWrapper
|
21
|
+
{
|
22
|
+
_eventEmitterCallback = std::move(eventEmitterCallbackWrapper->_eventEmitterCallback);
|
23
|
+
}
|
24
|
+
@end
|
25
|
+
|
26
|
+
@implementation RCTCxxConvert (NativeMobilyflowReactNativeSdk_MobilyPurchaseSDKOptions)
|
27
|
+
+ (RCTManagedPointer *)JS_NativeMobilyflowReactNativeSdk_MobilyPurchaseSDKOptions:(id)json
|
28
|
+
{
|
29
|
+
return facebook::react::managedPointer<JS::NativeMobilyflowReactNativeSdk::MobilyPurchaseSDKOptions>(json);
|
30
|
+
}
|
31
|
+
@end
|
32
|
+
@implementation RCTCxxConvert (NativeMobilyflowReactNativeSdk_PurchaseOptions)
|
33
|
+
+ (RCTManagedPointer *)JS_NativeMobilyflowReactNativeSdk_PurchaseOptions:(id)json
|
34
|
+
{
|
35
|
+
return facebook::react::managedPointer<JS::NativeMobilyflowReactNativeSdk::PurchaseOptions>(json);
|
36
|
+
}
|
37
|
+
@end
|
38
|
+
namespace facebook::react {
|
39
|
+
|
40
|
+
static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_instantiate(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
41
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, StringKind, "instantiate", @selector(instantiate:apiKey:environment:options:), args, count);
|
42
|
+
}
|
43
|
+
|
44
|
+
static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_close(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
45
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "close", @selector(close:), args, count);
|
46
|
+
}
|
47
|
+
|
48
|
+
static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_login(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
49
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "login", @selector(login:externalId:resolve:reject:), args, count);
|
50
|
+
}
|
51
|
+
|
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);
|
54
|
+
}
|
55
|
+
|
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);
|
58
|
+
}
|
59
|
+
|
60
|
+
static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getEntitlementForSubscription(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
61
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "getEntitlementForSubscription", @selector(getEntitlementForSubscription:subscriptionGroupId:resolve:reject:), args, count);
|
62
|
+
}
|
63
|
+
|
64
|
+
static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getEntitlement(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
65
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "getEntitlement", @selector(getEntitlement:productId:resolve:reject:), args, count);
|
66
|
+
}
|
67
|
+
|
68
|
+
static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getEntitlements(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
69
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "getEntitlements", @selector(getEntitlements:productIds:resolve:reject:), args, count);
|
70
|
+
}
|
71
|
+
|
72
|
+
static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_requestTransferOwnership(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
73
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "requestTransferOwnership", @selector(requestTransferOwnership:resolve:reject:), args, count);
|
74
|
+
}
|
75
|
+
|
76
|
+
static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_openManageSubscription(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
77
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "openManageSubscription", @selector(openManageSubscription:resolve:reject:), args, count);
|
78
|
+
}
|
79
|
+
|
80
|
+
static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_purchaseProduct(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
81
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "purchaseProduct", @selector(purchaseProduct:productId:options:resolve:reject:), args, count);
|
82
|
+
}
|
83
|
+
|
84
|
+
static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_sendDiagnotic(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
85
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, VoidKind, "sendDiagnotic", @selector(sendDiagnotic:), args, count);
|
86
|
+
}
|
87
|
+
|
88
|
+
static facebook::jsi::Value __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getStoreCountry(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
89
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "getStoreCountry", @selector(getStoreCountry:resolve:reject:), args, count);
|
90
|
+
}
|
91
|
+
|
92
|
+
NativeMobilyflowReactNativeSdkSpecJSI::NativeMobilyflowReactNativeSdkSpecJSI(const ObjCTurboModule::InitParams ¶ms)
|
93
|
+
: ObjCTurboModule(params) {
|
94
|
+
|
95
|
+
methodMap_["instantiate"] = MethodMetadata {4, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_instantiate};
|
96
|
+
setMethodArgConversionSelector(@"instantiate", 3, @"JS_NativeMobilyflowReactNativeSdk_MobilyPurchaseSDKOptions:");
|
97
|
+
|
98
|
+
methodMap_["close"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_close};
|
99
|
+
|
100
|
+
|
101
|
+
methodMap_["login"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_login};
|
102
|
+
|
103
|
+
|
104
|
+
methodMap_["getProducts"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getProducts};
|
105
|
+
|
106
|
+
|
107
|
+
methodMap_["getSubscriptionGroups"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getSubscriptionGroups};
|
108
|
+
|
109
|
+
|
110
|
+
methodMap_["getEntitlementForSubscription"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getEntitlementForSubscription};
|
111
|
+
|
112
|
+
|
113
|
+
methodMap_["getEntitlement"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getEntitlement};
|
114
|
+
|
115
|
+
|
116
|
+
methodMap_["getEntitlements"] = MethodMetadata {2, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getEntitlements};
|
117
|
+
|
118
|
+
|
119
|
+
methodMap_["requestTransferOwnership"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_requestTransferOwnership};
|
120
|
+
|
121
|
+
|
122
|
+
methodMap_["openManageSubscription"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_openManageSubscription};
|
123
|
+
|
124
|
+
|
125
|
+
methodMap_["purchaseProduct"] = MethodMetadata {3, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_purchaseProduct};
|
126
|
+
setMethodArgConversionSelector(@"purchaseProduct", 2, @"JS_NativeMobilyflowReactNativeSdk_PurchaseOptions:");
|
127
|
+
|
128
|
+
methodMap_["sendDiagnotic"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_sendDiagnotic};
|
129
|
+
|
130
|
+
|
131
|
+
methodMap_["getStoreCountry"] = MethodMetadata {1, __hostFunction_NativeMobilyflowReactNativeSdkSpecJSI_getStoreCountry};
|
132
|
+
|
133
|
+
}
|
134
|
+
} // namespace facebook::react
|
@@ -0,0 +1,161 @@
|
|
1
|
+
/**
|
2
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
3
|
+
*
|
4
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
5
|
+
* once the code is regenerated.
|
6
|
+
*
|
7
|
+
* @generated by codegen project: GenerateModuleObjCpp
|
8
|
+
*
|
9
|
+
* We create an umbrella header (and corresponding implementation) here since
|
10
|
+
* Cxx compilation in BUCK has a limitation: source-code producing genrule()s
|
11
|
+
* must have a single output. More files => more genrule()s => slower builds.
|
12
|
+
*/
|
13
|
+
|
14
|
+
#ifndef __cplusplus
|
15
|
+
#error This file must be compiled as Obj-C++. If you are importing it, you must change your file extension to .mm.
|
16
|
+
#endif
|
17
|
+
|
18
|
+
// Avoid multiple includes of RNMobilyflowReactNativeSdkSpec symbols
|
19
|
+
#ifndef RNMobilyflowReactNativeSdkSpec_H
|
20
|
+
#define RNMobilyflowReactNativeSdkSpec_H
|
21
|
+
|
22
|
+
#import <Foundation/Foundation.h>
|
23
|
+
#import <RCTRequired/RCTRequired.h>
|
24
|
+
#import <RCTTypeSafety/RCTConvertHelpers.h>
|
25
|
+
#import <RCTTypeSafety/RCTTypedModuleConstants.h>
|
26
|
+
#import <React/RCTBridgeModule.h>
|
27
|
+
#import <React/RCTCxxConvert.h>
|
28
|
+
#import <React/RCTManagedPointer.h>
|
29
|
+
#import <ReactCommon/RCTTurboModule.h>
|
30
|
+
#import <optional>
|
31
|
+
#import <vector>
|
32
|
+
|
33
|
+
|
34
|
+
NS_ASSUME_NONNULL_BEGIN
|
35
|
+
namespace JS {
|
36
|
+
namespace NativeMobilyflowReactNativeSdk {
|
37
|
+
struct MobilyPurchaseSDKOptions {
|
38
|
+
std::optional<facebook::react::LazyVector<NSString *>> languages() const;
|
39
|
+
std::optional<bool> debug() const;
|
40
|
+
NSString *apiURL() const;
|
41
|
+
|
42
|
+
MobilyPurchaseSDKOptions(NSDictionary *const v) : _v(v) {}
|
43
|
+
private:
|
44
|
+
NSDictionary *_v;
|
45
|
+
};
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
@interface RCTCxxConvert (NativeMobilyflowReactNativeSdk_MobilyPurchaseSDKOptions)
|
50
|
+
+ (RCTManagedPointer *)JS_NativeMobilyflowReactNativeSdk_MobilyPurchaseSDKOptions:(id)json;
|
51
|
+
@end
|
52
|
+
namespace JS {
|
53
|
+
namespace NativeMobilyflowReactNativeSdk {
|
54
|
+
struct PurchaseOptions {
|
55
|
+
NSString *offerId() const;
|
56
|
+
double quantity() const;
|
57
|
+
|
58
|
+
PurchaseOptions(NSDictionary *const v) : _v(v) {}
|
59
|
+
private:
|
60
|
+
NSDictionary *_v;
|
61
|
+
};
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
@interface RCTCxxConvert (NativeMobilyflowReactNativeSdk_PurchaseOptions)
|
66
|
+
+ (RCTManagedPointer *)JS_NativeMobilyflowReactNativeSdk_PurchaseOptions:(id)json;
|
67
|
+
@end
|
68
|
+
@protocol NativeMobilyflowReactNativeSdkSpec <RCTBridgeModule, RCTTurboModule>
|
69
|
+
|
70
|
+
- (NSString *)instantiate:(NSString *)appId
|
71
|
+
apiKey:(NSString *)apiKey
|
72
|
+
environment:(double)environment
|
73
|
+
options:(JS::NativeMobilyflowReactNativeSdk::MobilyPurchaseSDKOptions &)options;
|
74
|
+
- (void)close:(NSString *)uuid;
|
75
|
+
- (void)login:(NSString *)uuid
|
76
|
+
externalId:(NSString *)externalId
|
77
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
78
|
+
reject:(RCTPromiseRejectBlock)reject;
|
79
|
+
- (void)getProducts:(NSString *)uuid
|
80
|
+
identifiers:(NSArray *)identifiers
|
81
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
82
|
+
reject:(RCTPromiseRejectBlock)reject;
|
83
|
+
- (void)getSubscriptionGroups:(NSString *)uuid
|
84
|
+
identifiers:(NSArray *)identifiers
|
85
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
86
|
+
reject:(RCTPromiseRejectBlock)reject;
|
87
|
+
- (void)getEntitlementForSubscription:(NSString *)uuid
|
88
|
+
subscriptionGroupId:(NSString *)subscriptionGroupId
|
89
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
90
|
+
reject:(RCTPromiseRejectBlock)reject;
|
91
|
+
- (void)getEntitlement:(NSString *)uuid
|
92
|
+
productId:(NSString *)productId
|
93
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
94
|
+
reject:(RCTPromiseRejectBlock)reject;
|
95
|
+
- (void)getEntitlements:(NSString *)uuid
|
96
|
+
productIds:(NSArray *)productIds
|
97
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
98
|
+
reject:(RCTPromiseRejectBlock)reject;
|
99
|
+
- (void)requestTransferOwnership:(NSString *)uuid
|
100
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
101
|
+
reject:(RCTPromiseRejectBlock)reject;
|
102
|
+
- (void)openManageSubscription:(NSString *)uuid
|
103
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
104
|
+
reject:(RCTPromiseRejectBlock)reject;
|
105
|
+
- (void)purchaseProduct:(NSString *)uuid
|
106
|
+
productId:(NSString *)productId
|
107
|
+
options:(JS::NativeMobilyflowReactNativeSdk::PurchaseOptions &)options
|
108
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
109
|
+
reject:(RCTPromiseRejectBlock)reject;
|
110
|
+
- (void)sendDiagnotic:(NSString *)uuid;
|
111
|
+
- (void)getStoreCountry:(NSString *)uuid
|
112
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
113
|
+
reject:(RCTPromiseRejectBlock)reject;
|
114
|
+
|
115
|
+
@end
|
116
|
+
|
117
|
+
@interface NativeMobilyflowReactNativeSdkSpecBase : NSObject {
|
118
|
+
@protected
|
119
|
+
facebook::react::EventEmitterCallback _eventEmitterCallback;
|
120
|
+
}
|
121
|
+
- (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *)eventEmitterCallbackWrapper;
|
122
|
+
|
123
|
+
|
124
|
+
@end
|
125
|
+
|
126
|
+
namespace facebook::react {
|
127
|
+
/**
|
128
|
+
* ObjC++ class for module 'NativeMobilyflowReactNativeSdk'
|
129
|
+
*/
|
130
|
+
class JSI_EXPORT NativeMobilyflowReactNativeSdkSpecJSI : public ObjCTurboModule {
|
131
|
+
public:
|
132
|
+
NativeMobilyflowReactNativeSdkSpecJSI(const ObjCTurboModule::InitParams ¶ms);
|
133
|
+
};
|
134
|
+
} // namespace facebook::react
|
135
|
+
inline std::optional<facebook::react::LazyVector<NSString *>> JS::NativeMobilyflowReactNativeSdk::MobilyPurchaseSDKOptions::languages() const
|
136
|
+
{
|
137
|
+
id const p = _v[@"languages"];
|
138
|
+
return RCTBridgingToOptionalVec(p, ^NSString *(id itemValue_0) { return RCTBridgingToString(itemValue_0); });
|
139
|
+
}
|
140
|
+
inline std::optional<bool> JS::NativeMobilyflowReactNativeSdk::MobilyPurchaseSDKOptions::debug() const
|
141
|
+
{
|
142
|
+
id const p = _v[@"debug"];
|
143
|
+
return RCTBridgingToOptionalBool(p);
|
144
|
+
}
|
145
|
+
inline NSString *JS::NativeMobilyflowReactNativeSdk::MobilyPurchaseSDKOptions::apiURL() const
|
146
|
+
{
|
147
|
+
id const p = _v[@"apiURL"];
|
148
|
+
return RCTBridgingToOptionalString(p);
|
149
|
+
}
|
150
|
+
inline NSString *JS::NativeMobilyflowReactNativeSdk::PurchaseOptions::offerId() const
|
151
|
+
{
|
152
|
+
id const p = _v[@"offerId"];
|
153
|
+
return RCTBridgingToString(p);
|
154
|
+
}
|
155
|
+
inline double JS::NativeMobilyflowReactNativeSdk::PurchaseOptions::quantity() const
|
156
|
+
{
|
157
|
+
id const p = _v[@"quantity"];
|
158
|
+
return RCTBridgingToDouble(p);
|
159
|
+
}
|
160
|
+
NS_ASSUME_NONNULL_END
|
161
|
+
#endif // RNMobilyflowReactNativeSdkSpec_H
|