@adjoe/react-native-adjoe-sdk 0.0.0-stage → 5.1.3
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/README.md +33 -2
- package/android/build.gradle +93 -0
- package/android/src/main/AndroidManifest.xml +11 -0
- package/android/src/main/java/io/adjoe/sdk/reactnative/BasicUtil.kt +361 -0
- package/android/src/main/java/io/adjoe/sdk/reactnative/ErrorsUtil.kt +113 -0
- package/android/src/main/java/io/adjoe/sdk/reactnative/PlaytimeProtectionImpl.kt +150 -0
- package/android/src/main/java/io/adjoe/sdk/reactnative/PlaytimeStudioImpl.kt +313 -0
- package/android/src/main/java/io/adjoe/sdk/reactnative/RNPlaytimeSdkImpl.kt +173 -0
- package/android/src/main/java/io/adjoe/sdk/reactnative/RNPlaytimeSdkPackage.kt +55 -0
- package/android/src/main/java/io/adjoe/sdk/reactnative/StudioUtil.kt +421 -0
- package/android/src/main/java/io/adjoe/sdk/reactnative/Util.kt +40 -0
- package/android/src/newarch/java/io/adjoe/sdk/reactnative/RNPlaytimeProtection.kt +25 -0
- package/android/src/newarch/java/io/adjoe/sdk/reactnative/RNPlaytimeSdkModule.kt +57 -0
- package/android/src/newarch/java/io/adjoe/sdk/reactnative/RNPlaytimeStudio.kt +66 -0
- package/android/src/oldarch/java/io/adjoe/sdk/reactnative/RNPlaytimeProtection.kt +29 -0
- package/android/src/oldarch/java/io/adjoe/sdk/reactnative/RNPlaytimeSdkModule.kt +68 -0
- package/android/src/oldarch/java/io/adjoe/sdk/reactnative/RNPlaytimeStudio.kt +83 -0
- package/ios/AdjoeSdk.xcodeproj/project.pbxproj +281 -0
- package/ios/AdjoeSdk.xcodeproj/xcuserdata/hamid.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
- package/ios/AdjoeSdk.xcworkspace/contents.xcworkspacedata +7 -0
- package/ios/ErrorsUtil.swift +180 -0
- package/ios/PlaytimeProtectionImpl.swift +20 -0
- package/ios/PlaytimeSdkImpl.swift +173 -0
- package/ios/PlaytimeStudioImpl.swift +272 -0
- package/ios/RNPlaytimeBasic.mm +187 -0
- package/ios/RNPlaytimeHelpers.h +21 -0
- package/ios/RNPlaytimeHelpers.m +94 -0
- package/ios/RNPlaytimeProtection.mm +77 -0
- package/ios/RNPlaytimeStudio.mm +265 -0
- package/package.json +35 -4
- package/react-native-adjoe-sdk.podspec +30 -0
- package/src/Playtime.js +158 -0
- package/src/PlaytimeException.js +140 -0
- package/src/PlaytimeProtection.js +40 -0
- package/src/PlaytimeStudio.js +110 -0
- package/src/index.js +8 -0
- package/src/specs/NativePlaytimeProtection.ts +9 -0
- package/src/specs/NativePlaytimeStudio.ts +23 -0
- package/src/specs/NativeRNPlaytimeSdk.ts +17 -0
- package/src-ts/Playtime.d.ts +407 -0
- package/src-ts/PlaytimeException.d.ts +87 -0
- package/src-ts/PlaytimeProtection.d.ts +106 -0
- package/src-ts/PlaytimeStudio.d.ts +818 -0
- package/src-ts/index.d.ts +8 -0
- package/tsconfig.json +114 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// RNPlaytimeHelpers.m
|
|
2
|
+
|
|
3
|
+
#import "RNPlaytimeHelpers.h"
|
|
4
|
+
|
|
5
|
+
@implementation RNPlaytimeHelpers
|
|
6
|
+
|
|
7
|
+
/// Parses an ISO 8601 date string coming from JavaScript.
|
|
8
|
+
///
|
|
9
|
+
/// JS has no date type on the bridge, so `PlaytimeUserProfile.birthday` is sent as a
|
|
10
|
+
/// string (typically from `Date.prototype.toISOString()`). The SDK's
|
|
11
|
+
/// `init(JSONObject:)` expects a real `NSDate` and casts without parsing, so the
|
|
12
|
+
/// conversion has to happen here.
|
|
13
|
+
///
|
|
14
|
+
/// Both the fractional-seconds form (`2002-12-02T00:00:00.000Z`) and the plain form
|
|
15
|
+
/// (`2002-12-02T00:00:00Z`) are accepted, as is a bare calendar date
|
|
16
|
+
/// (`2002-12-02`), which is the natural way to express a birthday.
|
|
17
|
+
+ (NSDate * _Nullable)dateFromISOString:(NSString *)value
|
|
18
|
+
{
|
|
19
|
+
if (value.length == 0) {
|
|
20
|
+
return nil;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static NSISO8601DateFormatter *withFractionalSeconds = nil;
|
|
24
|
+
static NSISO8601DateFormatter *withoutFractionalSeconds = nil;
|
|
25
|
+
static NSISO8601DateFormatter *dateOnly = nil;
|
|
26
|
+
static dispatch_once_t onceToken;
|
|
27
|
+
dispatch_once(&onceToken, ^{
|
|
28
|
+
withFractionalSeconds = [[NSISO8601DateFormatter alloc] init];
|
|
29
|
+
withFractionalSeconds.formatOptions = NSISO8601DateFormatWithInternetDateTime
|
|
30
|
+
| NSISO8601DateFormatWithFractionalSeconds;
|
|
31
|
+
|
|
32
|
+
withoutFractionalSeconds = [[NSISO8601DateFormatter alloc] init];
|
|
33
|
+
withoutFractionalSeconds.formatOptions = NSISO8601DateFormatWithInternetDateTime;
|
|
34
|
+
|
|
35
|
+
dateOnly = [[NSISO8601DateFormatter alloc] init];
|
|
36
|
+
dateOnly.formatOptions = NSISO8601DateFormatWithFullDate;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
for (NSISO8601DateFormatter *formatter in @[ withFractionalSeconds,
|
|
40
|
+
withoutFractionalSeconds,
|
|
41
|
+
dateOnly ]) {
|
|
42
|
+
NSDate *date = [formatter dateFromString:value];
|
|
43
|
+
if (date != nil) {
|
|
44
|
+
return date;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return nil;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/// Returns a copy of the user profile with `birthday` converted from an ISO 8601 string
|
|
52
|
+
/// to an `NSDate`. An unparseable or empty value is dropped rather than forwarded, so the
|
|
53
|
+
/// SDK sees "no birthday" instead of throwing a type mismatch.
|
|
54
|
+
+ (NSDictionary * _Nullable)normalizedUserProfile:(id)userProfile
|
|
55
|
+
{
|
|
56
|
+
if (![userProfile isKindOfClass:[NSDictionary class]]) {
|
|
57
|
+
return nil;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
NSMutableDictionary *profile = [(NSDictionary *)userProfile mutableCopy];
|
|
61
|
+
id birthday = profile[@"birthday"];
|
|
62
|
+
|
|
63
|
+
if ([birthday isKindOfClass:[NSString class]]) {
|
|
64
|
+
NSDate *parsed = [self dateFromISOString:(NSString *)birthday];
|
|
65
|
+
if (parsed != nil) {
|
|
66
|
+
profile[@"birthday"] = parsed;
|
|
67
|
+
} else {
|
|
68
|
+
[profile removeObjectForKey:@"birthday"];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return profile;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
+ (InitOptions *)initOptionsFromDictionary:(NSDictionary *)paramsDictionary error:(NSError **)error
|
|
76
|
+
{
|
|
77
|
+
NSMutableDictionary *mutableParams = [paramsDictionary mutableCopy];
|
|
78
|
+
mutableParams[@"wrapper"] = @"rn";
|
|
79
|
+
|
|
80
|
+
NSDictionary *userProfile = [self normalizedUserProfile:mutableParams[@"userProfile"]];
|
|
81
|
+
if (userProfile != nil) {
|
|
82
|
+
mutableParams[@"userProfile"] = userProfile;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
InitOptions *initOptions = [[InitOptions alloc] initWithJSONObject:mutableParams error:error];
|
|
86
|
+
|
|
87
|
+
if (initOptions == nil || *error != nil) {
|
|
88
|
+
return nil;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return initOptions;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
|
2
|
+
#import <React/RCTLog.h>
|
|
3
|
+
|
|
4
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
5
|
+
#import "RNPlaytimeSdkSpec.h"
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
#if __has_include(<react_native_adjoe_sdk/react_native_adjoe_sdk-Swift.h>)
|
|
9
|
+
#import <react_native_adjoe_sdk/react_native_adjoe_sdk-Swift.h>
|
|
10
|
+
#else
|
|
11
|
+
#import "react_native_adjoe_sdk-Swift.h"
|
|
12
|
+
#endif
|
|
13
|
+
|
|
14
|
+
@interface RNPlaytimeProtection : NSObject <RCTBridgeModule>
|
|
15
|
+
@end
|
|
16
|
+
|
|
17
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
18
|
+
@interface RNPlaytimeProtection () <NativePlaytimeProtectionSpec>
|
|
19
|
+
@end
|
|
20
|
+
#endif
|
|
21
|
+
|
|
22
|
+
@implementation RNPlaytimeProtection {
|
|
23
|
+
PlaytimeProtectionImpl *_impl;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
RCT_EXPORT_MODULE(PlaytimeProtection)
|
|
27
|
+
|
|
28
|
+
- (instancetype)init
|
|
29
|
+
{
|
|
30
|
+
if (self = [super init]) {
|
|
31
|
+
_impl = [PlaytimeProtectionImpl new];
|
|
32
|
+
}
|
|
33
|
+
return self;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
+ (BOOL)requiresMainQueueSetup
|
|
37
|
+
{
|
|
38
|
+
return YES;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
42
|
+
|
|
43
|
+
- (void)faceVerification:(RCTPromiseResolveBlock)resolve
|
|
44
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
45
|
+
{
|
|
46
|
+
[_impl faceVerification:resolve reject:reject];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
- (void)faceVerificationStatus:(RCTPromiseResolveBlock)resolve
|
|
50
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
51
|
+
{
|
|
52
|
+
[_impl faceVerificationStatus:resolve reject:reject];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
56
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
57
|
+
{
|
|
58
|
+
return std::make_shared<facebook::react::NativePlaytimeProtectionSpecJSI>(params);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
#else // Old Architecture (legacy bridge)
|
|
62
|
+
|
|
63
|
+
RCT_EXPORT_METHOD(faceVerification:(RCTPromiseResolveBlock)resolve
|
|
64
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
65
|
+
{
|
|
66
|
+
[_impl faceVerification:resolve reject:reject];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
RCT_EXPORT_METHOD(faceVerificationStatus:(RCTPromiseResolveBlock)resolve
|
|
70
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
71
|
+
{
|
|
72
|
+
[_impl faceVerificationStatus:resolve reject:reject];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
76
|
+
|
|
77
|
+
@end
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
|
2
|
+
#import <React/RCTLog.h>
|
|
3
|
+
|
|
4
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
5
|
+
#import "RNPlaytimeSdkSpec.h"
|
|
6
|
+
#endif
|
|
7
|
+
|
|
8
|
+
#if __has_include(<react_native_adjoe_sdk/react_native_adjoe_sdk-Swift.h>)
|
|
9
|
+
#import <react_native_adjoe_sdk/react_native_adjoe_sdk-Swift.h>
|
|
10
|
+
#else
|
|
11
|
+
#import "react_native_adjoe_sdk-Swift.h"
|
|
12
|
+
#endif
|
|
13
|
+
|
|
14
|
+
@interface RNPlaytimeStudio : NSObject <RCTBridgeModule>
|
|
15
|
+
@end
|
|
16
|
+
|
|
17
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
18
|
+
@interface RNPlaytimeStudio () <NativePlaytimeStudioSpec>
|
|
19
|
+
@end
|
|
20
|
+
#endif
|
|
21
|
+
|
|
22
|
+
@implementation RNPlaytimeStudio {
|
|
23
|
+
PlaytimeStudioImpl *_impl;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
RCT_EXPORT_MODULE(PlaytimeStudio)
|
|
27
|
+
|
|
28
|
+
- (instancetype)init
|
|
29
|
+
{
|
|
30
|
+
if (self = [super init]) {
|
|
31
|
+
_impl = [PlaytimeStudioImpl new];
|
|
32
|
+
}
|
|
33
|
+
return self;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
+ (BOOL)requiresMainQueueSetup
|
|
37
|
+
{
|
|
38
|
+
return YES;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
42
|
+
|
|
43
|
+
- (void)updateTosConsent:(double)action
|
|
44
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
45
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
46
|
+
{
|
|
47
|
+
[_impl updateTosConsent:action resolve:resolve reject:reject];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
- (void)getCampaigns:(NSDictionary *)options
|
|
51
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
52
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
53
|
+
{
|
|
54
|
+
[_impl getCampaigns:options resolve:resolve reject:reject];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
- (void)getOfferDetails:(NSArray *)tokens
|
|
58
|
+
campaignOptions:(NSDictionary *)options
|
|
59
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
60
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
61
|
+
{
|
|
62
|
+
[_impl getOfferDetails:tokens campaignOptions:options resolve:resolve reject:reject];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
- (void)getInstalledCampaigns:(NSDictionary *)options
|
|
66
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
67
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
68
|
+
{
|
|
69
|
+
[_impl getInstalledCampaigns:options resolve:resolve reject:reject];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
- (void)openInStore:(NSDictionary *)campaign
|
|
73
|
+
useInlineInstall:(BOOL)useInlineInstall
|
|
74
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
75
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
76
|
+
{
|
|
77
|
+
[_impl openInStore:campaign useInlineInstall:useInlineInstall resolve:resolve reject:reject];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
- (void)openInstalledCampaign:(NSDictionary *)campaign
|
|
81
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
82
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
83
|
+
{
|
|
84
|
+
[_impl openInstalledCampaign:campaign resolve:resolve reject:reject];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
- (void)openChatbot:(NSDictionary *)campaign
|
|
88
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
89
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
90
|
+
{
|
|
91
|
+
[_impl openChatbot:campaign resolve:resolve reject:reject];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
- (void)resetRewardsConnect:(RCTPromiseResolveBlock)resolve
|
|
95
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
96
|
+
{
|
|
97
|
+
[_impl resetRewardsConnect:resolve reject:reject];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
- (void)executeCampaignImpression:(NSDictionary *)campaign
|
|
101
|
+
impressionType:(double)impressionType
|
|
102
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
103
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
104
|
+
{
|
|
105
|
+
[_impl executeCampaignImpression:campaign impressionType:impressionType resolve:resolve reject:reject];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
- (void)executeOfferImpression:(NSString *)token
|
|
109
|
+
appID:(NSString *)appID
|
|
110
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
111
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
112
|
+
{
|
|
113
|
+
[_impl executeOfferImpression:token appID:appID resolve:resolve reject:reject];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
- (void)registerRewardsConnect:(RCTPromiseResolveBlock)resolve
|
|
117
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
118
|
+
{
|
|
119
|
+
[_impl registerRewardsConnect:resolve reject:reject];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
- (void)showCampaignDetails:(NSDictionary *)campaign
|
|
123
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
124
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
125
|
+
{
|
|
126
|
+
[_impl showCampaignDetails:campaign resolve:resolve reject:reject];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
- (void)showOfferDetails:(NSString *)token
|
|
130
|
+
appID:(NSString *)appID
|
|
131
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
132
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
133
|
+
{
|
|
134
|
+
[_impl showOfferDetails:token appID:appID resolve:resolve reject:reject];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
- (void)showInstalledCampaigns:(RCTPromiseResolveBlock)resolve
|
|
138
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
139
|
+
{
|
|
140
|
+
[_impl showInstalledCampaigns:resolve reject:reject];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
- (void)showPermissionsPrompt:(RCTPromiseResolveBlock)resolve
|
|
144
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
145
|
+
{
|
|
146
|
+
[_impl showPermissionsPrompt:resolve reject:reject];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
150
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
151
|
+
{
|
|
152
|
+
return std::make_shared<facebook::react::NativePlaytimeStudioSpecJSI>(params);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
#else // Old Architecture (legacy bridge)
|
|
156
|
+
|
|
157
|
+
RCT_EXPORT_METHOD(updateTosConsent:(double)action
|
|
158
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
159
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
160
|
+
{
|
|
161
|
+
[_impl updateTosConsent:action resolve:resolve reject:reject];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
RCT_EXPORT_METHOD(getCampaigns:(NSDictionary *)options
|
|
165
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
166
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
167
|
+
{
|
|
168
|
+
[_impl getCampaigns:options resolve:resolve reject:reject];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
RCT_EXPORT_METHOD(getOfferDetails:(NSArray *)tokens
|
|
172
|
+
campaignOptions:(NSDictionary *)options
|
|
173
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
174
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
175
|
+
{
|
|
176
|
+
[_impl getOfferDetails:tokens campaignOptions:options resolve:resolve reject:reject];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
RCT_EXPORT_METHOD(getInstalledCampaigns:(NSDictionary *)options
|
|
180
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
181
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
182
|
+
{
|
|
183
|
+
[_impl getInstalledCampaigns:options resolve:resolve reject:reject];
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
RCT_EXPORT_METHOD(openInStore:(NSDictionary *)campaign
|
|
187
|
+
useInlineInstall:(BOOL)useInlineInstall
|
|
188
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
189
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
190
|
+
{
|
|
191
|
+
[_impl openInStore:campaign useInlineInstall:useInlineInstall resolve:resolve reject:reject];
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
RCT_EXPORT_METHOD(openInstalledCampaign:(NSDictionary *)campaign
|
|
195
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
196
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
197
|
+
{
|
|
198
|
+
[_impl openInstalledCampaign:campaign resolve:resolve reject:reject];
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
RCT_EXPORT_METHOD(openChatbot:(NSDictionary *)campaign
|
|
202
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
203
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
204
|
+
{
|
|
205
|
+
[_impl openChatbot:campaign resolve:resolve reject:reject];
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
RCT_EXPORT_METHOD(resetRewardsConnect:(RCTPromiseResolveBlock)resolve
|
|
209
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
210
|
+
{
|
|
211
|
+
[_impl resetRewardsConnect:resolve reject:reject];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
RCT_EXPORT_METHOD(executeCampaignImpression:(NSDictionary *)campaign
|
|
215
|
+
impressionType:(double)impressionType
|
|
216
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
217
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
218
|
+
{
|
|
219
|
+
[_impl executeCampaignImpression:campaign impressionType:impressionType resolve:resolve reject:reject];
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
RCT_EXPORT_METHOD(executeOfferImpression:(NSString *)token
|
|
223
|
+
appID:(NSString *)appID
|
|
224
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
225
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
226
|
+
{
|
|
227
|
+
[_impl executeOfferImpression:token appID:appID resolve:resolve reject:reject];
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
RCT_EXPORT_METHOD(registerRewardsConnect:(RCTPromiseResolveBlock)resolve
|
|
231
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
232
|
+
{
|
|
233
|
+
[_impl registerRewardsConnect:resolve reject:reject];
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
RCT_EXPORT_METHOD(showCampaignDetails:(NSDictionary *)campaign
|
|
237
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
238
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
239
|
+
{
|
|
240
|
+
[_impl showCampaignDetails:campaign resolve:resolve reject:reject];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
RCT_EXPORT_METHOD(showOfferDetails:(NSString *)token
|
|
244
|
+
appID:(NSString *)appID
|
|
245
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
246
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
247
|
+
{
|
|
248
|
+
[_impl showOfferDetails:token appID:appID resolve:resolve reject:reject];
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
RCT_EXPORT_METHOD(showInstalledCampaigns:(RCTPromiseResolveBlock)resolve
|
|
252
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
253
|
+
{
|
|
254
|
+
[_impl showInstalledCampaigns:resolve reject:reject];
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
RCT_EXPORT_METHOD(showPermissionsPrompt:(RCTPromiseResolveBlock)resolve
|
|
258
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
259
|
+
{
|
|
260
|
+
[_impl showPermissionsPrompt:resolve reject:reject];
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
#endif
|
|
264
|
+
|
|
265
|
+
@end
|
package/package.json
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adjoe/react-native-adjoe-sdk",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"description": "React Native adjoe SDK",
|
|
4
|
+
"version": "5.1.3",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"types": "src-ts/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"react-native"
|
|
12
|
+
],
|
|
13
|
+
"author": "adjoe GmbH <support@adjoe.atlassian.net>",
|
|
14
|
+
"license": "UNLICENSED",
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"react": "*",
|
|
17
|
+
"react-native": ">=0.76.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"clean-publish": "^1.1.8",
|
|
21
|
+
"publish-variants": "^1.0.4",
|
|
22
|
+
"react": "19.1.0",
|
|
23
|
+
"react-native": "0.81.4",
|
|
24
|
+
"typescript": "^5.2.2"
|
|
25
|
+
},
|
|
26
|
+
"codegenConfig": {
|
|
27
|
+
"name": "RNPlaytimeSdkSpec",
|
|
28
|
+
"type": "modules",
|
|
29
|
+
"jsSrcsDir": "src/specs",
|
|
30
|
+
"android": {
|
|
31
|
+
"javaPackageName": "io.adjoe.sdk.reactnative"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# react-native-adjoe-sdk.podspec
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
6
|
+
|
|
7
|
+
Pod::Spec.new do |s|
|
|
8
|
+
s.name = "react-native-adjoe-sdk"
|
|
9
|
+
s.version = package["version"]
|
|
10
|
+
s.summary = "Monetization solution for iOS"
|
|
11
|
+
s.description = "A native iOS monetization solution for app publishers aiming to boost revenue and engagement through rewarded gaming and app interactions."
|
|
12
|
+
s.license = { :type => 'Commercial', :text => 'adjoe GmbH' }
|
|
13
|
+
s.homepage = "https://adjoe.io/solutions/monetize-your-app/playtime/"
|
|
14
|
+
s.platforms = { :ios => '13.0' }
|
|
15
|
+
s.source = { :git => "https://github.com/github_account/react-native-adjoe-sdk.git", :tag => "#{s.version}" }
|
|
16
|
+
s.author = { "adjoe" => "support@adjoe.atlassian.net" }
|
|
17
|
+
|
|
18
|
+
# Includes the Objective-C++ TurboModule shims (.mm), the Swift logic classes
|
|
19
|
+
# (.swift) and the shared ObjC helper (.h/.m).
|
|
20
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
21
|
+
s.requires_arc = true
|
|
22
|
+
|
|
23
|
+
s.dependency 'PlaytimeSDK', '5.1.3'
|
|
24
|
+
|
|
25
|
+
# Wires up the New Architecture (TurboModules) dependencies and the
|
|
26
|
+
# RCT_NEW_ARCH_ENABLED / Codegen setup. Provided by the React Native pod
|
|
27
|
+
# scripts; on the legacy architecture it falls back to depending on
|
|
28
|
+
# React-Core.
|
|
29
|
+
install_modules_dependencies(s)
|
|
30
|
+
end
|
package/src/Playtime.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import RNPlaytimeSdk from './specs/NativeRNPlaytimeSdk';
|
|
2
|
+
import { wrapPlaytimePromise } from './PlaytimeException';
|
|
3
|
+
import { DisplayFormat } from './PlaytimeStudio';
|
|
4
|
+
import { NativeEventEmitter } from 'react-native';
|
|
5
|
+
|
|
6
|
+
const getPlaytimeParams = (params, uaChannel) => {
|
|
7
|
+
// if first params is an object then proceed as playtimeParams
|
|
8
|
+
// otherwise first params is uaNetwork
|
|
9
|
+
var playtimeParams = {};
|
|
10
|
+
if (typeof params === "object" && params !== null) {
|
|
11
|
+
playtimeParams = params;
|
|
12
|
+
} else if (typeof params === "string") {
|
|
13
|
+
playtimeParams["uaNetwork"] = params;
|
|
14
|
+
if (uaChannel !== null) {
|
|
15
|
+
playtimeParams["uaChannel"] = uaChannel;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return playtimeParams;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const PlaytimeCampaignsState = Object.freeze({
|
|
22
|
+
READY: 0,
|
|
23
|
+
BLOCKED: 1,
|
|
24
|
+
VPN_DETECTED: 2,
|
|
25
|
+
GEO_MISMATCH: 3,
|
|
26
|
+
NOT_INITIALIZED: 4,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const PlaytimeGender = Object.freeze({
|
|
30
|
+
MALE: 0,
|
|
31
|
+
FEMALE: 1,
|
|
32
|
+
UNKNOWN: 2,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const CatalogPlacement = Object.freeze({
|
|
36
|
+
Navbar: 'navbar',
|
|
37
|
+
Icon: 'icon',
|
|
38
|
+
EarnTab: 'earn_tab',
|
|
39
|
+
GameTab: 'game_tab',
|
|
40
|
+
HomePage: 'home_page',
|
|
41
|
+
NotificationInbox: 'notification_inbox',
|
|
42
|
+
Notification: 'notification',
|
|
43
|
+
MiniGame: 'mini_game',
|
|
44
|
+
OrderPage: 'order_page',
|
|
45
|
+
RedeemSection: 'redeem_section',
|
|
46
|
+
ScanReceipt: 'scan_receipt',
|
|
47
|
+
StepConverter: 'step_converter',
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export const AppCategory = Object.freeze({
|
|
51
|
+
GAMING: 'gaming',
|
|
52
|
+
NON_GAMING: 'non-gaming',
|
|
53
|
+
BOTH: 'both',
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const isCustomValue = (value, predefined) =>
|
|
57
|
+
!Object.values(predefined).includes(value);
|
|
58
|
+
|
|
59
|
+
const sealedValue = (value, predefined, supportsCustom) => {
|
|
60
|
+
if (value === null || value === undefined) {
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
// Already normalized (or a value built by an earlier call) -- keep it as is so
|
|
64
|
+
// normalization stays idempotent.
|
|
65
|
+
if (typeof value === 'object') {
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
if (!supportsCustom) {
|
|
69
|
+
return { value };
|
|
70
|
+
}
|
|
71
|
+
return { value, isCustom: isCustomValue(value, predefined) };
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// TODO: currently there is a known issue here, placement key is used for both
|
|
75
|
+
// CatalogPlacement & StudioPlacement. Since both models have the same values
|
|
76
|
+
// it is not a issue currently, but this should be addressed at some point.
|
|
77
|
+
const SEALED_OPTION_FIELDS = Object.freeze({
|
|
78
|
+
placement: [CatalogPlacement, true],
|
|
79
|
+
category: [AppCategory, false],
|
|
80
|
+
displayFormat: [DisplayFormat, true],
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
export const normalizeSealedOptions = (options) => {
|
|
84
|
+
if (options === null || options === undefined || typeof options !== 'object') {
|
|
85
|
+
return options;
|
|
86
|
+
}
|
|
87
|
+
const normalized = { ...options };
|
|
88
|
+
for (const [key, [predefined, supportsCustom]] of Object.entries(SEALED_OPTION_FIELDS)) {
|
|
89
|
+
if (key in normalized) {
|
|
90
|
+
normalized[key] = sealedValue(normalized[key], predefined, supportsCustom);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return normalized;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// endregion
|
|
97
|
+
|
|
98
|
+
// region Playtime SDK events
|
|
99
|
+
//
|
|
100
|
+
// A publisher-supplied listener object cannot cross the native bridge, so events are
|
|
101
|
+
// delivered through a NativeEventEmitter instead: the native side emits a device event
|
|
102
|
+
// under PLAYTIME_EVENT_NAME, and this module forwards each one to the registered
|
|
103
|
+
// listener's `didReceive` callback. The hand-written logic below is NOT regenerated.
|
|
104
|
+
|
|
105
|
+
const PLAYTIME_EVENT_NAME = 'onPlaytimeEvent';
|
|
106
|
+
|
|
107
|
+
const playtimeEventEmitter = new NativeEventEmitter(RNPlaytimeSdk);
|
|
108
|
+
|
|
109
|
+
// The JS-side subscription bridging the native device event to the publisher's listener.
|
|
110
|
+
let playtimeEventSubscription = null;
|
|
111
|
+
|
|
112
|
+
// endregion
|
|
113
|
+
|
|
114
|
+
export default {
|
|
115
|
+
initPlaytime: function(options) {
|
|
116
|
+
return wrapPlaytimePromise(RNPlaytimeSdk.initPlaytime(options));
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
showCatalog: function(catalogOptions) {
|
|
120
|
+
return wrapPlaytimePromise(RNPlaytimeSdk.showCatalog(normalizeSealedOptions(catalogOptions)));
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
teardown: function() {
|
|
124
|
+
return wrapPlaytimePromise(RNPlaytimeSdk.teardown());
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
getStatus: function() {
|
|
128
|
+
return wrapPlaytimePromise(RNPlaytimeSdk.getStatus());
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
addEventListener: function(eventListener) {
|
|
132
|
+
if (playtimeEventSubscription !== null) {
|
|
133
|
+
playtimeEventSubscription.remove();
|
|
134
|
+
playtimeEventSubscription = null;
|
|
135
|
+
}
|
|
136
|
+
playtimeEventSubscription = playtimeEventEmitter.addListener(
|
|
137
|
+
PLAYTIME_EVENT_NAME,
|
|
138
|
+
function(event) {
|
|
139
|
+
eventListener.didReceive(event);
|
|
140
|
+
}
|
|
141
|
+
);
|
|
142
|
+
return wrapPlaytimePromise(RNPlaytimeSdk.addEventListener());
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
removeEventListener: function() {
|
|
146
|
+
if (playtimeEventSubscription !== null) {
|
|
147
|
+
playtimeEventSubscription.remove();
|
|
148
|
+
playtimeEventSubscription = null;
|
|
149
|
+
}
|
|
150
|
+
return wrapPlaytimePromise(RNPlaytimeSdk.removeEventListener());
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
executeImpressionEvent: function(catalogPlacement) {
|
|
154
|
+
return wrapPlaytimePromise(
|
|
155
|
+
RNPlaytimeSdk.executeImpressionEvent(sealedValue(catalogPlacement, CatalogPlacement, true))
|
|
156
|
+
);
|
|
157
|
+
},
|
|
158
|
+
};
|