@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.
Files changed (45) hide show
  1. package/README.md +33 -2
  2. package/android/build.gradle +93 -0
  3. package/android/src/main/AndroidManifest.xml +11 -0
  4. package/android/src/main/java/io/adjoe/sdk/reactnative/BasicUtil.kt +361 -0
  5. package/android/src/main/java/io/adjoe/sdk/reactnative/ErrorsUtil.kt +113 -0
  6. package/android/src/main/java/io/adjoe/sdk/reactnative/PlaytimeProtectionImpl.kt +150 -0
  7. package/android/src/main/java/io/adjoe/sdk/reactnative/PlaytimeStudioImpl.kt +313 -0
  8. package/android/src/main/java/io/adjoe/sdk/reactnative/RNPlaytimeSdkImpl.kt +173 -0
  9. package/android/src/main/java/io/adjoe/sdk/reactnative/RNPlaytimeSdkPackage.kt +55 -0
  10. package/android/src/main/java/io/adjoe/sdk/reactnative/StudioUtil.kt +421 -0
  11. package/android/src/main/java/io/adjoe/sdk/reactnative/Util.kt +40 -0
  12. package/android/src/newarch/java/io/adjoe/sdk/reactnative/RNPlaytimeProtection.kt +25 -0
  13. package/android/src/newarch/java/io/adjoe/sdk/reactnative/RNPlaytimeSdkModule.kt +57 -0
  14. package/android/src/newarch/java/io/adjoe/sdk/reactnative/RNPlaytimeStudio.kt +66 -0
  15. package/android/src/oldarch/java/io/adjoe/sdk/reactnative/RNPlaytimeProtection.kt +29 -0
  16. package/android/src/oldarch/java/io/adjoe/sdk/reactnative/RNPlaytimeSdkModule.kt +68 -0
  17. package/android/src/oldarch/java/io/adjoe/sdk/reactnative/RNPlaytimeStudio.kt +83 -0
  18. package/ios/AdjoeSdk.xcodeproj/project.pbxproj +281 -0
  19. package/ios/AdjoeSdk.xcodeproj/xcuserdata/hamid.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  20. package/ios/AdjoeSdk.xcworkspace/contents.xcworkspacedata +7 -0
  21. package/ios/ErrorsUtil.swift +180 -0
  22. package/ios/PlaytimeProtectionImpl.swift +20 -0
  23. package/ios/PlaytimeSdkImpl.swift +173 -0
  24. package/ios/PlaytimeStudioImpl.swift +272 -0
  25. package/ios/RNPlaytimeBasic.mm +187 -0
  26. package/ios/RNPlaytimeHelpers.h +21 -0
  27. package/ios/RNPlaytimeHelpers.m +94 -0
  28. package/ios/RNPlaytimeProtection.mm +77 -0
  29. package/ios/RNPlaytimeStudio.mm +265 -0
  30. package/package.json +35 -4
  31. package/react-native-adjoe-sdk.podspec +30 -0
  32. package/src/Playtime.js +158 -0
  33. package/src/PlaytimeException.js +140 -0
  34. package/src/PlaytimeProtection.js +40 -0
  35. package/src/PlaytimeStudio.js +110 -0
  36. package/src/index.js +8 -0
  37. package/src/specs/NativePlaytimeProtection.ts +9 -0
  38. package/src/specs/NativePlaytimeStudio.ts +23 -0
  39. package/src/specs/NativeRNPlaytimeSdk.ts +17 -0
  40. package/src-ts/Playtime.d.ts +407 -0
  41. package/src-ts/PlaytimeException.d.ts +87 -0
  42. package/src-ts/PlaytimeProtection.d.ts +106 -0
  43. package/src-ts/PlaytimeStudio.d.ts +818 -0
  44. package/src-ts/index.d.ts +8 -0
  45. package/tsconfig.json +114 -0
@@ -0,0 +1,68 @@
1
+ package io.adjoe.sdk.reactnative
2
+
3
+ import com.facebook.react.bridge.Promise
4
+ import com.facebook.react.bridge.ReactApplicationContext
5
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
6
+ import com.facebook.react.bridge.ReactMethod
7
+ import com.facebook.react.bridge.ReadableMap
8
+ import com.facebook.react.module.annotations.ReactModule
9
+
10
+ @ReactModule(name = RNPlaytimeSdkImpl.NAME)
11
+ class RNPlaytimeSdkModule(
12
+ reactContext: ReactApplicationContext
13
+ ) : ReactContextBaseJavaModule(reactContext) {
14
+
15
+ private val implementation = RNPlaytimeSdkImpl(reactContext)
16
+
17
+ override fun getName(): String = RNPlaytimeSdkImpl.NAME
18
+
19
+ @ReactMethod
20
+ fun initPlaytime(options: ReadableMap?, promise: Promise) {
21
+ implementation.initPlaytime(options, promise)
22
+ }
23
+
24
+ @ReactMethod
25
+ fun showCatalog(catalogOptions: ReadableMap?, promise: Promise) {
26
+ implementation.showCatalog(catalogOptions, promise)
27
+ }
28
+
29
+ @ReactMethod
30
+ fun getStatus(promise: Promise) {
31
+ implementation.getStatus(promise)
32
+ }
33
+
34
+ @ReactMethod
35
+ fun teardown(promise: Promise) {
36
+ implementation.teardown(promise)
37
+ }
38
+
39
+ @ReactMethod
40
+ fun addEventListener(promise: Promise) {
41
+ implementation.addEventListener(promise)
42
+ }
43
+
44
+ @ReactMethod
45
+ fun removeEventListener(promise: Promise) {
46
+ implementation.removeEventListener(promise)
47
+ }
48
+
49
+ @ReactMethod
50
+ fun addListener(eventName: String) {
51
+ // Required so the JS NativeEventEmitter has a native counterpart on the old
52
+ // architecture. Event delivery is driven by the SDK listener.
53
+ }
54
+
55
+ @ReactMethod
56
+ fun removeListeners(count: Double) {
57
+ // Required by the NativeEventEmitter contract; see addListener.
58
+ }
59
+
60
+ @ReactMethod
61
+ fun executeImpressionEvent(catalogPlacement: ReadableMap?, promise: Promise) {
62
+ implementation.executeImpressionEvent(catalogPlacement, promise)
63
+ }
64
+
65
+ companion object {
66
+ const val NAME = RNPlaytimeSdkImpl.NAME
67
+ }
68
+ }
@@ -0,0 +1,83 @@
1
+ package io.adjoe.sdk.reactnative
2
+
3
+ import com.facebook.react.bridge.Promise
4
+ import com.facebook.react.bridge.ReactApplicationContext
5
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
6
+ import com.facebook.react.bridge.ReactMethod
7
+ import com.facebook.react.bridge.ReadableArray
8
+ import com.facebook.react.bridge.ReadableMap
9
+ import com.facebook.react.module.annotations.ReactModule
10
+
11
+ @ReactModule(name = PlaytimeStudioImpl.NAME)
12
+ class RNPlaytimeStudio(
13
+ reactContext: ReactApplicationContext
14
+ ) : ReactContextBaseJavaModule(reactContext) {
15
+
16
+ private val implementation = PlaytimeStudioImpl(reactContext)
17
+
18
+ override fun getName(): String = PlaytimeStudioImpl.NAME
19
+
20
+ @ReactMethod
21
+ fun updateTosConsent(action: Double, promise: Promise) =
22
+ implementation.updateTosConsent(action, promise)
23
+
24
+ @ReactMethod
25
+ fun getCampaigns(campaignOptionsMap: ReadableMap?, promise: Promise) =
26
+ implementation.getCampaigns(campaignOptionsMap, promise)
27
+
28
+ @ReactMethod
29
+ fun getOfferDetails(tokens: ReadableArray?, campaignOptionsMap: ReadableMap?, promise: Promise) =
30
+ implementation.getOfferDetails(tokens, campaignOptionsMap, promise)
31
+
32
+ @ReactMethod
33
+ fun getInstalledCampaigns(optionsMap: ReadableMap?, promise: Promise) =
34
+ implementation.getInstalledCampaigns(optionsMap, promise)
35
+
36
+ @ReactMethod
37
+ fun openInStore(campaignMap: ReadableMap?, useInlineInstall: Boolean, promise: Promise) =
38
+ implementation.openInStore(campaignMap, useInlineInstall, promise)
39
+
40
+ @ReactMethod
41
+ fun openInstalledCampaign(campaignMap: ReadableMap?, promise: Promise) =
42
+ implementation.openInstalledCampaign(campaignMap, promise)
43
+
44
+ @ReactMethod
45
+ fun openChatbot(campaignMap: ReadableMap?, promise: Promise) =
46
+ implementation.openChatbot(campaignMap, promise)
47
+
48
+ @ReactMethod
49
+ fun resetRewardsConnect(promise: Promise) =
50
+ implementation.resetRewardsConnect(promise)
51
+
52
+ @ReactMethod
53
+ fun executeCampaignImpression(campaignMap: ReadableMap?, impressionType: Double, promise: Promise) =
54
+ implementation.executeCampaignImpression(campaignMap, impressionType, promise)
55
+
56
+ @ReactMethod
57
+ fun executeOfferImpression(token: String, appID: String, promise: Promise) =
58
+ implementation.executeOfferImpression(token, appID, promise)
59
+
60
+ @ReactMethod
61
+ fun registerRewardsConnect(promise: Promise) =
62
+ implementation.registerRewardsConnect(promise)
63
+
64
+ @ReactMethod
65
+ fun showCampaignDetails(campaignMap: ReadableMap?, promise: Promise) =
66
+ implementation.showCampaignDetails(campaignMap, promise)
67
+
68
+ @ReactMethod
69
+ fun showOfferDetails(token: String, appID: String, promise: Promise) =
70
+ implementation.showOfferDetails(token, appID, promise)
71
+
72
+ @ReactMethod
73
+ fun showInstalledCampaigns(promise: Promise) =
74
+ implementation.showInstalledCampaigns(promise)
75
+
76
+ @ReactMethod
77
+ fun showPermissionsPrompt(promise: Promise) =
78
+ implementation.showPermissionsPrompt(promise)
79
+
80
+ companion object {
81
+ const val NAME = PlaytimeStudioImpl.NAME
82
+ }
83
+ }
@@ -0,0 +1,281 @@
1
+ // !$*UTF8*$!
2
+ {
3
+ archiveVersion = 1;
4
+ classes = {
5
+ };
6
+ objectVersion = 46;
7
+ objects = {
8
+
9
+ /* Begin PBXCopyFilesBuildPhase section */
10
+ 58B511D91A9E6C8500147676 /* CopyFiles */ = {
11
+ isa = PBXCopyFilesBuildPhase;
12
+ buildActionMask = 2147483647;
13
+ dstPath = "include/$(PRODUCT_NAME)";
14
+ dstSubfolderSpec = 16;
15
+ files = (
16
+ );
17
+ runOnlyForDeploymentPostprocessing = 0;
18
+ };
19
+ /* End PBXCopyFilesBuildPhase section */
20
+
21
+ /* Begin PBXFileReference section */
22
+ 134814201AA4EA6300B7C361 /* libAdjoeSdk.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAdjoeSdk.a; sourceTree = BUILT_PRODUCTS_DIR; };
23
+ /* End PBXFileReference section */
24
+
25
+ /* Begin PBXFrameworksBuildPhase section */
26
+ 58B511D81A9E6C8500147676 /* Frameworks */ = {
27
+ isa = PBXFrameworksBuildPhase;
28
+ buildActionMask = 2147483647;
29
+ files = (
30
+ );
31
+ runOnlyForDeploymentPostprocessing = 0;
32
+ };
33
+ /* End PBXFrameworksBuildPhase section */
34
+
35
+ /* Begin PBXGroup section */
36
+ 134814211AA4EA7D00B7C361 /* Products */ = {
37
+ isa = PBXGroup;
38
+ children = (
39
+ 134814201AA4EA6300B7C361 /* libAdjoeSdk.a */,
40
+ );
41
+ name = Products;
42
+ sourceTree = "<group>";
43
+ };
44
+ 58B511D21A9E6C8500147676 = {
45
+ isa = PBXGroup;
46
+ children = (
47
+ 134814211AA4EA7D00B7C361 /* Products */,
48
+ );
49
+ sourceTree = "<group>";
50
+ };
51
+ /* End PBXGroup section */
52
+
53
+ /* Begin PBXNativeTarget section */
54
+ 58B511DA1A9E6C8500147676 /* AdjoeSdk */ = {
55
+ isa = PBXNativeTarget;
56
+ buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "AdjoeSdk" */;
57
+ buildPhases = (
58
+ 58B511D71A9E6C8500147676 /* Sources */,
59
+ 58B511D81A9E6C8500147676 /* Frameworks */,
60
+ 58B511D91A9E6C8500147676 /* CopyFiles */,
61
+ );
62
+ buildRules = (
63
+ );
64
+ dependencies = (
65
+ );
66
+ name = AdjoeSdk;
67
+ productName = RCTDataManager;
68
+ productReference = 134814201AA4EA6300B7C361 /* libAdjoeSdk.a */;
69
+ productType = "com.apple.product-type.library.static";
70
+ };
71
+ /* End PBXNativeTarget section */
72
+
73
+ /* Begin PBXProject section */
74
+ 58B511D31A9E6C8500147676 /* Project object */ = {
75
+ isa = PBXProject;
76
+ attributes = {
77
+ LastUpgradeCheck = 0920;
78
+ ORGANIZATIONNAME = Facebook;
79
+ TargetAttributes = {
80
+ 58B511DA1A9E6C8500147676 = {
81
+ CreatedOnToolsVersion = 6.1.1;
82
+ };
83
+ };
84
+ };
85
+ buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "AdjoeSdk" */;
86
+ compatibilityVersion = "Xcode 3.2";
87
+ developmentRegion = en;
88
+ hasScannedForEncodings = 0;
89
+ knownRegions = (
90
+ en,
91
+ Base,
92
+ );
93
+ mainGroup = 58B511D21A9E6C8500147676;
94
+ productRefGroup = 58B511D21A9E6C8500147676;
95
+ projectDirPath = "";
96
+ projectRoot = "";
97
+ targets = (
98
+ 58B511DA1A9E6C8500147676 /* AdjoeSdk */,
99
+ );
100
+ };
101
+ /* End PBXProject section */
102
+
103
+ /* Begin PBXSourcesBuildPhase section */
104
+ 58B511D71A9E6C8500147676 /* Sources */ = {
105
+ isa = PBXSourcesBuildPhase;
106
+ buildActionMask = 2147483647;
107
+ files = (
108
+ );
109
+ runOnlyForDeploymentPostprocessing = 0;
110
+ };
111
+ /* End PBXSourcesBuildPhase section */
112
+
113
+ /* Begin XCBuildConfiguration section */
114
+ 58B511ED1A9E6C8500147676 /* Debug */ = {
115
+ isa = XCBuildConfiguration;
116
+ buildSettings = {
117
+ ALWAYS_SEARCH_USER_PATHS = NO;
118
+ CLANG_ANALYZER_NONNULL = YES;
119
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
120
+ CLANG_CXX_LIBRARY = "libc++";
121
+ CLANG_ENABLE_MODULES = YES;
122
+ CLANG_ENABLE_OBJC_ARC = YES;
123
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
124
+ CLANG_WARN_BOOL_CONVERSION = YES;
125
+ CLANG_WARN_COMMA = YES;
126
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
127
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
128
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
129
+ CLANG_WARN_EMPTY_BODY = YES;
130
+ CLANG_WARN_ENUM_CONVERSION = YES;
131
+ CLANG_WARN_INFINITE_RECURSION = YES;
132
+ CLANG_WARN_INT_CONVERSION = YES;
133
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
134
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
135
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
136
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
137
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
138
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
139
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
140
+ CLANG_WARN_UNREACHABLE_CODE = YES;
141
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
142
+ COPY_PHASE_STRIP = NO;
143
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
144
+ ENABLE_TESTABILITY = YES;
145
+ GCC_C_LANGUAGE_STANDARD = gnu99;
146
+ GCC_DYNAMIC_NO_PIC = NO;
147
+ GCC_NO_COMMON_BLOCKS = YES;
148
+ GCC_OPTIMIZATION_LEVEL = 0;
149
+ GCC_PREPROCESSOR_DEFINITIONS = (
150
+ "DEBUG=1",
151
+ "$(inherited)",
152
+ );
153
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
154
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
155
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
156
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
157
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
158
+ GCC_WARN_UNUSED_FUNCTION = YES;
159
+ GCC_WARN_UNUSED_VARIABLE = YES;
160
+ IPHONEOS_DEPLOYMENT_TARGET = 13.0;
161
+ LD_RUNPATH_SEARCH_PATHS = "/usr/lib/swift $(inherited)";
162
+ LIBRARY_SEARCH_PATHS = (
163
+ "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
164
+ "\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"",
165
+ "\"$(inherited)\"",
166
+ );
167
+ MTL_ENABLE_DEBUG_INFO = YES;
168
+ ONLY_ACTIVE_ARCH = YES;
169
+ SDKROOT = iphoneos;
170
+ };
171
+ name = Debug;
172
+ };
173
+ 58B511EE1A9E6C8500147676 /* Release */ = {
174
+ isa = XCBuildConfiguration;
175
+ buildSettings = {
176
+ ALWAYS_SEARCH_USER_PATHS = NO;
177
+ CLANG_ANALYZER_NONNULL = YES;
178
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
179
+ CLANG_CXX_LIBRARY = "libc++";
180
+ CLANG_ENABLE_MODULES = YES;
181
+ CLANG_ENABLE_OBJC_ARC = YES;
182
+ CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
183
+ CLANG_WARN_BOOL_CONVERSION = YES;
184
+ CLANG_WARN_COMMA = YES;
185
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
186
+ CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
187
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
188
+ CLANG_WARN_EMPTY_BODY = YES;
189
+ CLANG_WARN_ENUM_CONVERSION = YES;
190
+ CLANG_WARN_INFINITE_RECURSION = YES;
191
+ CLANG_WARN_INT_CONVERSION = YES;
192
+ CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
193
+ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
194
+ CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
195
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
196
+ CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
197
+ CLANG_WARN_STRICT_PROTOTYPES = YES;
198
+ CLANG_WARN_SUSPICIOUS_MOVE = YES;
199
+ CLANG_WARN_UNREACHABLE_CODE = YES;
200
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
201
+ COPY_PHASE_STRIP = YES;
202
+ ENABLE_NS_ASSERTIONS = NO;
203
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
204
+ GCC_C_LANGUAGE_STANDARD = gnu99;
205
+ GCC_NO_COMMON_BLOCKS = YES;
206
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
207
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
208
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
209
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
210
+ GCC_WARN_UNUSED_FUNCTION = YES;
211
+ GCC_WARN_UNUSED_VARIABLE = YES;
212
+ IPHONEOS_DEPLOYMENT_TARGET = 13.0;
213
+ LD_RUNPATH_SEARCH_PATHS = "/usr/lib/swift $(inherited)";
214
+ LIBRARY_SEARCH_PATHS = (
215
+ "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"",
216
+ "\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"",
217
+ "\"$(inherited)\"",
218
+ );
219
+ MTL_ENABLE_DEBUG_INFO = NO;
220
+ SDKROOT = iphoneos;
221
+ VALIDATE_PRODUCT = YES;
222
+ };
223
+ name = Release;
224
+ };
225
+ 58B511F01A9E6C8500147676 /* Debug */ = {
226
+ isa = XCBuildConfiguration;
227
+ buildSettings = {
228
+ HEADER_SEARCH_PATHS = (
229
+ "$(inherited)",
230
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
231
+ "$(SRCROOT)/../../../React/**",
232
+ "$(SRCROOT)/../../react-native/React/**",
233
+ );
234
+ LIBRARY_SEARCH_PATHS = "$(inherited)";
235
+ OTHER_LDFLAGS = "-ObjC";
236
+ PRODUCT_NAME = AdjoeSdk;
237
+ SKIP_INSTALL = YES;
238
+ };
239
+ name = Debug;
240
+ };
241
+ 58B511F11A9E6C8500147676 /* Release */ = {
242
+ isa = XCBuildConfiguration;
243
+ buildSettings = {
244
+ HEADER_SEARCH_PATHS = (
245
+ "$(inherited)",
246
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
247
+ "$(SRCROOT)/../../../React/**",
248
+ "$(SRCROOT)/../../react-native/React/**",
249
+ );
250
+ LIBRARY_SEARCH_PATHS = "$(inherited)";
251
+ OTHER_LDFLAGS = "-ObjC";
252
+ PRODUCT_NAME = AdjoeSdk;
253
+ SKIP_INSTALL = YES;
254
+ };
255
+ name = Release;
256
+ };
257
+ /* End XCBuildConfiguration section */
258
+
259
+ /* Begin XCConfigurationList section */
260
+ 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "AdjoeSdk" */ = {
261
+ isa = XCConfigurationList;
262
+ buildConfigurations = (
263
+ 58B511ED1A9E6C8500147676 /* Debug */,
264
+ 58B511EE1A9E6C8500147676 /* Release */,
265
+ );
266
+ defaultConfigurationIsVisible = 0;
267
+ defaultConfigurationName = Debug;
268
+ };
269
+ 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "AdjoeSdk" */ = {
270
+ isa = XCConfigurationList;
271
+ buildConfigurations = (
272
+ 58B511F01A9E6C8500147676 /* Debug */,
273
+ 58B511F11A9E6C8500147676 /* Release */,
274
+ );
275
+ defaultConfigurationIsVisible = 0;
276
+ defaultConfigurationName = Debug;
277
+ };
278
+ /* End XCConfigurationList section */
279
+ };
280
+ rootObject = 58B511D31A9E6C8500147676 /* Project object */;
281
+ }
@@ -0,0 +1,14 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>SchemeUserState</key>
6
+ <dict>
7
+ <key>AdjoeSdk.xcscheme_^#shared#^_</key>
8
+ <dict>
9
+ <key>orderHint</key>
10
+ <integer>57</integer>
11
+ </dict>
12
+ </dict>
13
+ </dict>
14
+ </plist>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "group:AdjoeSdk.xcodeproj">
6
+ </FileRef>
7
+ </Workspace>
@@ -0,0 +1,180 @@
1
+ import Foundation
2
+ import React
3
+ import PlaytimeSDK
4
+
5
+ enum ErrorsUtil {
6
+
7
+ /// Key names of the `userInfo` payload. Must stay in sync with the JS/Android side.
8
+ enum UserInfoKey {
9
+ static let code = "code"
10
+ static let errorType = "errorType"
11
+ static let isRetryable = "isRetryable"
12
+ }
13
+
14
+ /// The `NSError` domain of the rejection payload.
15
+ ///
16
+ /// `PlaytimeException` is a plain `NSObject`, so it carries no domain of its
17
+ /// own and the wrapper supplies one.
18
+ private static let errorDomain = "io.adjoe.sdk.reactnative.PlaytimeException"
19
+
20
+ /// `PlaytimeException.code` is non-optional, so wrapper-created exceptions
21
+ /// pass an empty code, which is serialized as `null` for the JS side.
22
+ private static let unspecifiedCode = ""
23
+
24
+ /// `PlaytimeException.isRetryable` is non-optional, so wrapper-created
25
+ /// exceptions pass this default when the flag cannot be populated.
26
+ private static let unspecifiedIsRetryable = false
27
+
28
+ private static let unknownErrorMessage = "Unknown error occurred"
29
+
30
+ // MARK: - Factories
31
+
32
+ /// A feature that is not available on iOS was invoked.
33
+ static func notImplementedError(_ message: String = "Function is not implemented") -> PlaytimeException {
34
+ return PlaytimeException(
35
+ code: unspecifiedCode,
36
+ errorType: .sdkConfig,
37
+ isRetryable: unspecifiedIsRetryable,
38
+ message: message
39
+ )
40
+ }
41
+
42
+ /// Builds a generic error for a failed wrapper function.
43
+ static func getFunctionError(_ functionName: String, reason: String? = nil) -> PlaytimeException {
44
+ guard let reason = reason, !reason.isEmpty else {
45
+ return PlaytimeException(
46
+ code: unspecifiedCode,
47
+ errorType: .unknown,
48
+ isRetryable: unspecifiedIsRetryable,
49
+ message: "Error occurred during \(functionName)"
50
+ )
51
+ }
52
+
53
+ return PlaytimeException(
54
+ code: unspecifiedCode,
55
+ errorType: .unknown,
56
+ isRetryable: unspecifiedIsRetryable,
57
+ message: "Error occurred during \(functionName): \(reason)"
58
+ )
59
+ }
60
+
61
+ // MARK: - Coercion
62
+
63
+ /// Coerces an arbitrary `Error` into a ``PlaytimeException``.
64
+ ///
65
+ /// If the error already is a ``PlaytimeException`` it is returned unchanged.
66
+ static func toPlaytimeException(_ error: Error?) -> PlaytimeException {
67
+ if let playtimeException = error as? PlaytimeException {
68
+ return playtimeException
69
+ }
70
+
71
+ guard let error = error else {
72
+ return PlaytimeException(
73
+ code: unspecifiedCode,
74
+ errorType: .unknown,
75
+ isRetryable: unspecifiedIsRetryable,
76
+ message: unknownErrorMessage
77
+ )
78
+ }
79
+
80
+ return PlaytimeException(
81
+ code: unspecifiedCode,
82
+ errorType: .unknown,
83
+ isRetryable: unspecifiedIsRetryable,
84
+ message: error.localizedDescription
85
+ )
86
+ }
87
+
88
+ // MARK: - Category
89
+
90
+ /// Maps the SDK's `Int`-backed category onto the UPPER_SNAKE wire value
91
+ /// shared with Android and JavaScript.
92
+ ///
93
+ /// The raw value must not be used: it is an ordinal, whereas the JS
94
+ /// `PlaytimeErrorType` enum is deliberately string-based.
95
+ private static func errorTypeName(_ errorType: PlaytimeErrorType) -> String {
96
+ switch errorType {
97
+ case .network:
98
+ return "NETWORK"
99
+ case .networkVPN:
100
+ return "NETWORK_VPN"
101
+ case .api:
102
+ return "API"
103
+ case .responseFormat:
104
+ return "RESPONSE_FORMAT"
105
+ case .sdkConfig:
106
+ return "SDK_CONFIG"
107
+ case .unknown:
108
+ return "UNKNOWN"
109
+ @unknown default:
110
+ return "UNKNOWN"
111
+ }
112
+ }
113
+
114
+ // MARK: - Rejection
115
+
116
+ /// Rejects with the structured representation of `exception`.
117
+ ///
118
+ /// `underlyingError` is the error the exception was coerced from, if any. It
119
+ /// is attached for debugging only and does not cross the bridge.
120
+ static func reject(
121
+ _ reject: RCTPromiseRejectBlock,
122
+ _ exception: PlaytimeException,
123
+ underlyingError: Error? = nil
124
+ ) {
125
+ var userInfo: [String: Any] = [:]
126
+
127
+ userInfo[UserInfoKey.code] = exception.code.isEmpty ? NSNull() : exception.code
128
+ userInfo[UserInfoKey.errorType] = errorTypeName(exception.errorType)
129
+ userInfo[UserInfoKey.isRetryable] = exception.isRetryable
130
+
131
+ let message = exception.message.isEmpty ? unknownErrorMessage : exception.message
132
+ userInfo[NSLocalizedDescriptionKey] = message
133
+
134
+ if let underlyingError = underlyingError {
135
+ userInfo[NSUnderlyingErrorKey] = underlyingError as NSError
136
+ }
137
+
138
+ let error = NSError(
139
+ domain: errorDomain,
140
+ code: 0,
141
+ userInfo: userInfo
142
+ )
143
+
144
+ reject(errorTypeName(exception.errorType), message, error)
145
+ }
146
+
147
+ /// Convenience: coerce any error and reject with it.
148
+ static func reject(_ reject: RCTPromiseRejectBlock, _ error: Error?) {
149
+ self.reject(reject, toPlaytimeException(error), underlyingError: error)
150
+ }
151
+
152
+ /// Coerce any error and reject with it, falling back to `context` as the
153
+ /// message when the underlying error carries none, while preserving the
154
+ /// classification of that error.
155
+ static func reject(_ reject: RCTPromiseRejectBlock, context: String, _ error: Error?) {
156
+ let exception = toPlaytimeException(error)
157
+ let message = exception.message.isEmpty ? context : exception.message
158
+
159
+ self.reject(
160
+ reject,
161
+ PlaytimeException(
162
+ code: exception.code,
163
+ errorType: exception.errorType,
164
+ isRetryable: exception.isRetryable,
165
+ message: message
166
+ ),
167
+ underlyingError: error
168
+ )
169
+ }
170
+
171
+ /// Convenience: reject with a generic function error.
172
+ static func reject(_ reject: RCTPromiseRejectBlock, function: String, reason: String? = nil) {
173
+ self.reject(reject, getFunctionError(function, reason: reason))
174
+ }
175
+
176
+ /// Convenience: reject because the operation is unsupported on iOS.
177
+ static func rejectUnsupported(_ name: String, _ reject: RCTPromiseRejectBlock) {
178
+ self.reject(reject, notImplementedError("\(name) is not supported on iOS"))
179
+ }
180
+ }
@@ -0,0 +1,20 @@
1
+ import Foundation
2
+ import React
3
+
4
+ /// iOS implementation of the `PlaytimeProtection` TurboModule.
5
+ ///
6
+ /// The protection features are provided by the Android SDK only, so every
7
+ /// method here is a stub that rejects as unsupported. The members still have to
8
+ /// exist because the Codegen-generated protocol is shared across platforms.
9
+ @objc public class PlaytimeProtectionImpl: NSObject {
10
+
11
+ @objc public func faceVerification(_ resolve: @escaping RCTPromiseResolveBlock,
12
+ reject: @escaping RCTPromiseRejectBlock) {
13
+ ErrorsUtil.rejectUnsupported("faceVerification", reject)
14
+ }
15
+
16
+ @objc public func faceVerificationStatus(_ resolve: @escaping RCTPromiseResolveBlock,
17
+ reject: @escaping RCTPromiseRejectBlock) {
18
+ ErrorsUtil.rejectUnsupported("faceVerificationStatus", reject)
19
+ }
20
+ }