@adadapted/react-native-sdk 3.3.0 → 3.5.0

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 (87) hide show
  1. package/android/bin/build.gradle +9 -8
  2. package/android/bin/gradle.properties +1 -1
  3. package/android/build.gradle +17 -80
  4. package/android/gradle.properties +2 -2
  5. package/android/src/main/java/com/adadaptedreactnativesdk/AdadaptedReactNativeSdkModule.kt +39 -54
  6. package/ios/AdadaptedReactNativeSdk.m +1 -1
  7. package/lib/commonjs/api/adadaptedApiRequests.js +12 -12
  8. package/lib/commonjs/api/adadaptedApiRequests.js.map +1 -1
  9. package/lib/commonjs/api/adadaptedApiRequests.mock.js.map +1 -1
  10. package/lib/commonjs/api/adadaptedApiTypes.js +5 -10
  11. package/lib/commonjs/api/adadaptedApiTypes.js.map +1 -1
  12. package/lib/commonjs/componentTypes/AdZone.js +11 -0
  13. package/lib/commonjs/componentTypes/AdZone.js.map +1 -0
  14. package/lib/commonjs/componentTypes/Device.js +22 -0
  15. package/lib/commonjs/componentTypes/Device.js.map +1 -0
  16. package/lib/commonjs/componentTypes/Environment.js +34 -0
  17. package/lib/commonjs/componentTypes/Environment.js.map +1 -0
  18. package/lib/commonjs/components/AdZone.js +76 -85
  19. package/lib/commonjs/components/AdZone.js.map +1 -1
  20. package/lib/commonjs/components/ReportAdButton.js +9 -7
  21. package/lib/commonjs/components/ReportAdButton.js.map +1 -1
  22. package/lib/commonjs/index.js +108 -132
  23. package/lib/commonjs/index.js.map +1 -1
  24. package/lib/commonjs/package.json +1 -0
  25. package/lib/commonjs/types.js.map +1 -1
  26. package/lib/commonjs/util.js +1 -4
  27. package/lib/commonjs/util.js.map +1 -1
  28. package/lib/module/api/adadaptedApiRequests.js +11 -9
  29. package/lib/module/api/adadaptedApiRequests.js.map +1 -1
  30. package/lib/module/api/adadaptedApiRequests.mock.js +2 -0
  31. package/lib/module/api/adadaptedApiRequests.mock.js.map +1 -1
  32. package/lib/module/api/adadaptedApiTypes.js +16 -0
  33. package/lib/module/api/adadaptedApiTypes.js.map +1 -1
  34. package/lib/module/componentTypes/AdZone.js +7 -0
  35. package/lib/module/componentTypes/AdZone.js.map +1 -0
  36. package/lib/module/componentTypes/Device.js +18 -0
  37. package/lib/module/componentTypes/Device.js.map +1 -0
  38. package/lib/module/componentTypes/Environment.js +30 -0
  39. package/lib/module/componentTypes/Environment.js.map +1 -0
  40. package/lib/module/components/AdZone.js +70 -80
  41. package/lib/module/components/AdZone.js.map +1 -1
  42. package/lib/module/components/ReportAdButton.js +9 -5
  43. package/lib/module/components/ReportAdButton.js.map +1 -1
  44. package/lib/module/index.js +102 -130
  45. package/lib/module/index.js.map +1 -1
  46. package/lib/module/package.json +1 -0
  47. package/lib/module/types.js +2 -0
  48. package/lib/module/types.js.map +1 -1
  49. package/lib/module/util.js +5 -5
  50. package/lib/module/util.js.map +1 -1
  51. package/lib/typescript/src/api/adadaptedApiRequests.d.ts +10 -9
  52. package/lib/typescript/src/api/adadaptedApiRequests.d.ts.map +1 -1
  53. package/lib/typescript/src/api/adadaptedApiTypes.d.ts +11 -0
  54. package/lib/typescript/src/api/adadaptedApiTypes.d.ts.map +1 -1
  55. package/lib/typescript/src/componentTypes/AdZone.d.ts +95 -0
  56. package/lib/typescript/src/componentTypes/AdZone.d.ts.map +1 -0
  57. package/lib/typescript/src/componentTypes/Device.d.ts +80 -0
  58. package/lib/typescript/src/componentTypes/Device.d.ts.map +1 -0
  59. package/lib/typescript/src/componentTypes/Environment.d.ts +57 -0
  60. package/lib/typescript/src/componentTypes/Environment.d.ts.map +1 -0
  61. package/lib/typescript/src/components/AdZone.d.ts +5 -54
  62. package/lib/typescript/src/components/AdZone.d.ts.map +1 -1
  63. package/lib/typescript/src/components/ReportAdButton.d.ts +2 -2
  64. package/lib/typescript/src/components/ReportAdButton.d.ts.map +1 -1
  65. package/lib/typescript/src/index.d.ts +34 -139
  66. package/lib/typescript/src/index.d.ts.map +1 -1
  67. package/package.json +10 -14
  68. package/src/api/adadaptedApiRequests.ts +25 -24
  69. package/src/api/adadaptedApiTypes.ts +11 -0
  70. package/src/componentTypes/AdZone.ts +97 -0
  71. package/src/componentTypes/Device.ts +79 -0
  72. package/src/componentTypes/Environment.ts +58 -0
  73. package/src/components/AdZone.tsx +82 -144
  74. package/src/components/ReportAdButton.tsx +1 -1
  75. package/src/index.tsx +168 -255
  76. package/lib/typescript/example/index.d.ts +0 -2
  77. package/lib/typescript/example/index.d.ts.map +0 -1
  78. package/lib/typescript/example/src/App.d.ts +0 -29
  79. package/lib/typescript/example/src/App.d.ts.map +0 -1
  80. package/lib/typescript/example/src/OffScreenAdZone.d.ts +0 -38
  81. package/lib/typescript/example/src/OffScreenAdZone.d.ts.map +0 -1
  82. package/lib/typescript/example/src/StandardAdZone.d.ts +0 -38
  83. package/lib/typescript/example/src/StandardAdZone.d.ts.map +0 -1
  84. package/lib/typescript/index.d.ts +0 -2
  85. package/lib/typescript/index.d.ts.map +0 -1
  86. package/lib/typescript/jest.setup.d.ts +0 -6
  87. package/lib/typescript/jest.setup.d.ts.map +0 -1
package/src/index.tsx CHANGED
@@ -29,74 +29,8 @@ import { AdZone } from "./components/AdZone";
29
29
  import { safeInvoke } from "./util";
30
30
  import packageJson from "../package.json";
31
31
  import base64 from "react-native-base64";
32
-
33
- /**
34
- * Enum representing possible device operating systems.
35
- */
36
- export enum DeviceOS {
37
- /**
38
- * Represents the Android operating system.
39
- */
40
- ANDROID = "android",
41
- /**
42
- * Represents the iOS operating system.
43
- */
44
- IOS = "ios",
45
- }
46
-
47
- /**
48
- * Enum defining the different API environments.
49
- */
50
- export enum ApiEnv {
51
- /**
52
- * The production API environment.
53
- */
54
- Prod = "https://ads.adadapted.com",
55
- /**
56
- * The development API environment.
57
- */
58
- Dev = "https://sandbox.adadapted.com",
59
- /**
60
- * Used only for unit testing/mock data.
61
- */
62
- Mock = "MOCK_DATA",
63
- }
64
-
65
- /**
66
- * Enum defining the different API environments for List Manager.
67
- */
68
- export enum ListManagerApiEnv {
69
- /**
70
- * The production API environment.
71
- */
72
- Prod = "https://ec.adadapted.com",
73
- /**
74
- * The development API environment.
75
- */
76
- Dev = "https://sandec.adadapted.com",
77
- /**
78
- * Used only for unit testing/mocking data.
79
- */
80
- Mock = "MOCK_DATA",
81
- }
82
-
83
- /**
84
- * Enum defining the different API environments for the Payload Server.
85
- */
86
- export enum PayloadApiEnv {
87
- /**
88
- * The production API environment.
89
- */
90
- Prod = "https://payload.adadapted.com",
91
- /**
92
- * The development API environment.
93
- */
94
- Dev = "https://sandpayload.adadapted.com",
95
- /**
96
- * Used only for unit testing/mocking data.
97
- */
98
- Mock = "MOCK_DATA",
99
- }
32
+ import { DeviceTypes } from "./componentTypes/Device";
33
+ import { EnvironmentTypes } from "./componentTypes/Environment";
100
34
 
101
35
  /**
102
36
  * Interface defining inputs to the {@link Sdk.initialize: AdadaptedReactNativeSdk} method.
@@ -110,7 +44,7 @@ export interface InitializeProps {
110
44
  * The API environment.
111
45
  * If undefined, defaults to production.
112
46
  */
113
- apiEnv?: ApiEnv;
47
+ apiEnv?: EnvironmentTypes.ApiEnv;
114
48
  /**
115
49
  * Optional custom advertiserId to replace IDFA - ios only.
116
50
  */
@@ -141,71 +75,9 @@ export interface InitializeProps {
141
75
  */
142
76
  onOutOfAppPayloadAvailable?(payloads: OutOfAppDataPayload[]): void;
143
77
  /**
144
- * Ad zones that contain off-screen ads.
78
+ * Ad zone ids that contain off-screen ads.
145
79
  */
146
- offScreenAdZone?: [number];
147
- }
148
-
149
- /**
150
- * Interface defining properties of a user's Device.
151
- */
152
- export interface DeviceInfo {
153
- /**
154
- * The unique device ID.
155
- */
156
- udid: string;
157
- /**
158
- * The device name.
159
- */
160
- deviceName: string;
161
- /**
162
- * The operating system name.
163
- */
164
- systemName: string;
165
- /**
166
- * The operating system version.
167
- */
168
- systemVersion: string;
169
- /**
170
- * The device model.
171
- */
172
- deviceModel: string;
173
- /**
174
- * The device screen width.
175
- */
176
- deviceWidth: string;
177
- /**
178
- * The device screen height.
179
- */
180
- deviceHeight: string;
181
- /**
182
- * The device screen density.
183
- */
184
- deviceScreenDensity: string;
185
- /**
186
- * The current device local.
187
- */
188
- deviceLocale: string;
189
- /**
190
- * The device carrier name.
191
- */
192
- deviceCarrier: string;
193
- /**
194
- * The bundle ID.
195
- */
196
- bundleId: string;
197
- /**
198
- * The bundle version.
199
- */
200
- bundleVersion: string;
201
- /**
202
- * The current device timezone.
203
- */
204
- deviceTimezone: string;
205
- /**
206
- * If true, ad tracking is enabled for the device.
207
- */
208
- isAdTrackingEnabled: boolean;
80
+ offScreenAdZoneIds?: [number];
209
81
  }
210
82
 
211
83
  /**
@@ -219,7 +91,7 @@ export interface AdZoneInfo {
219
91
  /**
220
92
  * The ad zone component.
221
93
  */
222
- adZone: JSX.Element;
94
+ adZone: React.JSX.Element;
223
95
  }
224
96
 
225
97
  /**
@@ -241,19 +113,19 @@ export class AdadaptedReactNativeSdk {
241
113
  /**
242
114
  * The API environment to use when making API calls.
243
115
  */
244
- private apiEnv: ApiEnv;
116
+ private apiEnv: EnvironmentTypes.ApiEnv;
245
117
  /**
246
118
  * The API environment to use when making API calls for List Manager.
247
119
  */
248
- private listManagerApiEnv: ListManagerApiEnv;
120
+ private listManagerApiEnv: EnvironmentTypes.ListManagerApiEnv;
249
121
  /**
250
122
  * The API environment to use when making API calls for the Payload server.
251
123
  */
252
- private payloadApiEnv: PayloadApiEnv;
124
+ private payloadApiEnv: EnvironmentTypes.PayloadApiEnv;
253
125
  /**
254
126
  * The device operating system.
255
127
  */
256
- private deviceOs: DeviceOS | undefined;
128
+ private deviceOs: DeviceTypes.DeviceOS | undefined;
257
129
  /**
258
130
  * The session ID used for the API to properly identify a user.
259
131
  */
@@ -261,7 +133,7 @@ export class AdadaptedReactNativeSdk {
261
133
  /**
262
134
  * All device data gathered when "initialize" is called.
263
135
  */
264
- private deviceInfo: DeviceInfo | undefined;
136
+ private deviceInfo: DeviceTypes.DeviceInfo | undefined;
265
137
  /**
266
138
  * All current Session/Ad info.
267
139
  * This info can be refreshed based on the set interval.
@@ -275,6 +147,10 @@ export class AdadaptedReactNativeSdk {
275
147
  * The available off-screen ad zones.
276
148
  */
277
149
  private offScreenAdZones: AdZoneInfo[] = [];
150
+ /**
151
+ * The zone ids of the availible off-screen ad zones.
152
+ */
153
+ private offScreenAdZoneIds: number[] = [];
278
154
  /**
279
155
  * The touch sensitivity of the Ad Zone in both the X and Y directions.
280
156
  * This is used to determine the click/press sensitivity when the
@@ -333,13 +209,19 @@ export class AdadaptedReactNativeSdk {
333
209
  */
334
210
  private AppStateOnEventListener: EmitterSubscription | undefined;
335
211
  /**
336
- * Track ad zone visibility for off-screen ads.
212
+ * The current adzone visibility status.
337
213
  */
338
214
  private isAdZoneVisible: boolean = true;
339
215
  /**
340
- * Ad zones that contain off-screen ads..
216
+ * The ad context object.
341
217
  */
342
- private offScreenAdZone: [number] | undefined;
218
+ private adContext:
219
+ | {
220
+ contextIds: string[];
221
+ zoneIds: string[];
222
+ }
223
+ | undefined;
224
+
343
225
  /**
344
226
  * Gets the Session ID.
345
227
  * @returns the Session ID.
@@ -352,7 +234,7 @@ export class AdadaptedReactNativeSdk {
352
234
  * Gets the Device Info object.
353
235
  * @returns the Device Info object.
354
236
  */
355
- public getDeviceInfo(): DeviceInfo | undefined {
237
+ public getDeviceInfo(): DeviceTypes.DeviceInfo | undefined {
356
238
  return this.deviceInfo;
357
239
  }
358
240
 
@@ -372,13 +254,35 @@ export class AdadaptedReactNativeSdk {
372
254
  return this.offScreenAdZones;
373
255
  }
374
256
 
257
+ /**
258
+ * Sets an ad context to replace an ad zone's ads with contextual ads for recipes.
259
+ * @param adContext - Object containing the contextual term and the associted ad zone.
260
+ * @param adContext.contextIds - An array of contextual ad ids.
261
+ * @param adContext.zoneIds - An array of zone ids for applying contextual ads.
262
+ */
263
+ public setAdContext(adContext: {
264
+ contextIds: string[];
265
+ zoneIds: string[];
266
+ }): void {
267
+ this.adContext = adContext;
268
+ this.onRefreshAdZones(true);
269
+ }
270
+
271
+ /**
272
+ * Clear the contextual ads from ad zones to return standard ads to the ad zones.
273
+ */
274
+ public clearAdContext(): void {
275
+ this.adContext = undefined;
276
+ this.onRefreshAdZones(true);
277
+ }
278
+
375
279
  /**
376
280
  * @inheritDoc
377
281
  */
378
282
  constructor() {
379
- this.apiEnv = ApiEnv.Prod;
380
- this.listManagerApiEnv = ListManagerApiEnv.Prod;
381
- this.payloadApiEnv = PayloadApiEnv.Prod;
283
+ this.apiEnv = EnvironmentTypes.ApiEnv.Prod;
284
+ this.listManagerApiEnv = EnvironmentTypes.ListManagerApiEnv.Prod;
285
+ this.payloadApiEnv = EnvironmentTypes.PayloadApiEnv.Prod;
382
286
  this.onAdZonesRefreshed = () => {
383
287
  // Defaulting to empty method.
384
288
  };
@@ -410,108 +314,87 @@ export class AdadaptedReactNativeSdk {
410
314
  });
411
315
  }
412
316
 
413
- /**
414
- * Creates all Ad Zone Info objects based on provided Ad Zones.
415
- * @param adZones - The object of available zones.
416
- * @returns the array of Ad Zone Info objects.
417
- */
418
- private generateAdZones(adZones: { [key: number]: Zone }): AdZoneInfo[] {
419
- const adZoneInfoList: AdZoneInfo[] = [];
420
-
421
- for (const adZoneId in adZones) {
422
- if (Object.prototype.hasOwnProperty.call(adZones, adZoneId)) {
423
- this.offScreenAdZone?.forEach((zone) => {
424
- if (Number(adZones[adZoneId].id) !== zone) {
425
- adZoneInfoList.push({
426
- zoneId: adZones[adZoneId].id,
427
- adZone: (
428
- <AdZone
429
- key={adZoneId}
430
- appId={this.appId}
431
- sessionId={this.sessionId!}
432
- udid={this.deviceInfo!.udid}
433
- deviceOs={this.deviceOs!}
434
- apiEnv={this.apiEnv}
435
- xyDragDistanceAllowed={
436
- this.xyAdZoneDragDistanceAllowed || 25
437
- }
438
- adZoneData={adZones[adZoneId]}
439
- onAddToListTriggered={(items) => {
440
- safeInvoke(
441
- this.onAddToListTriggered,
442
- items
443
- );
444
- }}
445
- isAdZoneVisible={true}
446
- offScreenAdZone={false}
447
- />
448
- ),
449
- });
317
+ private adZoneTemplate(
318
+ adZones: { [key: number]: Zone },
319
+ zoneId: string,
320
+ offScreenAdZone: boolean
321
+ ): AdZoneInfo {
322
+ return {
323
+ zoneId: adZones[Number(zoneId)].id,
324
+ adZone: (
325
+ <AdZone
326
+ key={zoneId}
327
+ appId={this.appId}
328
+ sessionId={this.sessionId!}
329
+ udid={this.deviceInfo!.udid}
330
+ deviceOs={this.deviceOs!}
331
+ apiEnv={this.apiEnv}
332
+ xyDragDistanceAllowed={
333
+ this.xyAdZoneDragDistanceAllowed || 25
450
334
  }
451
- });
452
- }
453
- }
454
- return adZoneInfoList;
335
+ adZoneData={adZones[Number(zoneId)]}
336
+ onAddToListTriggered={(items) => {
337
+ safeInvoke(this.onAddToListTriggered, items);
338
+ }}
339
+ isAdZoneVisible={this.isAdZoneVisible}
340
+ offScreenAdZone={offScreenAdZone ? true : false}
341
+ isContextualAd={this.adContext ? true : false}
342
+ />
343
+ ),
344
+ };
455
345
  }
456
346
 
457
347
  /**
458
- * Creates all off-screen Ad Zone Info objects based on provided off-screen Ad Zones.
348
+ * Creates all Ad Zone Info objects based on provided Ad Zones.
459
349
  * @param adZones - The object of available zones.
460
- * @returns the array of off-screen Ad Zone Info objects.
350
+ * @param offScreenAdZone - True if an ad zone first renders out of view.
351
+ * @returns the array of Ad Zone Info objects.
461
352
  */
462
- private generateOffScreenAdZones(adZones: {
463
- [key: number]: Zone;
464
- }): AdZoneInfo[] {
353
+ private generateAdZones(
354
+ adZones: { [key: number]: Zone },
355
+ offScreenAdZone: boolean = false
356
+ ): AdZoneInfo[] {
465
357
  const adZoneInfoList: AdZoneInfo[] = [];
466
-
467
- for (const adZoneId in adZones) {
468
- if (Object.prototype.hasOwnProperty.call(adZones, adZoneId)) {
469
- this.offScreenAdZone?.forEach((zone) => {
470
- if (Number(adZones[adZoneId].id) === zone) {
471
- adZoneInfoList.push({
472
- zoneId: adZones[adZoneId].id,
473
- adZone: (
474
- <AdZone
475
- key={adZoneId}
476
- appId={this.appId}
477
- sessionId={this.sessionId!}
478
- udid={this.deviceInfo!.udid}
479
- deviceOs={this.deviceOs!}
480
- apiEnv={this.apiEnv}
481
- xyDragDistanceAllowed={
482
- this.xyAdZoneDragDistanceAllowed || 25
483
- }
484
- adZoneData={adZones[adZoneId]}
485
- onAddToListTriggered={(items) => {
486
- safeInvoke(
487
- this.onAddToListTriggered,
488
- items
489
- );
490
- }}
491
- isAdZoneVisible={this.isAdZoneVisible}
492
- offScreenAdZone={true}
493
- />
494
- ),
495
- });
358
+ const offScreenAdZoneList: AdZoneInfo[] = [];
359
+
360
+ if (offScreenAdZone) {
361
+ for (const adZoneId in adZones) {
362
+ if (Object.prototype.hasOwnProperty.call(adZones, adZoneId)) {
363
+ if (this.offScreenAdZoneIds.includes(Number(adZoneId))) {
364
+ offScreenAdZoneList.push(
365
+ this.adZoneTemplate(adZones, adZoneId, true)
366
+ );
496
367
  }
497
- });
368
+ }
369
+ }
370
+ } else {
371
+ for (const adZoneId in adZones) {
372
+ if (Object.prototype.hasOwnProperty.call(adZones, adZoneId)) {
373
+ adZoneInfoList.push(
374
+ this.adZoneTemplate(adZones, adZoneId, false)
375
+ );
376
+ }
498
377
  }
499
378
  }
500
- return adZoneInfoList;
379
+
380
+ return offScreenAdZone ? offScreenAdZoneList : adZoneInfoList;
501
381
  }
502
382
 
503
383
  /**
504
384
  * Triggered when session data is initialized or refreshed. Creates
505
385
  * a timer based on the session data refresh value.
386
+ * @param immediateRefresh - If true the ad zones are refreshed bypassing the timer.
506
387
  */
507
- private onRefreshAdZones(): void {
388
+ private onRefreshAdZones(immediateRefresh: boolean = false): void {
508
389
  // Get the amount of time we will wait until a refresh occurs.
509
390
  // We are setting a minimum refresh time of 5 minutes, so if a
510
391
  // value provided by the API is lower, we don't refresh too often.
511
- const timerMs =
512
- this.sessionInfo!.polling_interval_ms >= 300000
513
- ? this.sessionInfo!.polling_interval_ms
514
- : 300000;
392
+ // If there are contextual ads, we refresh immediately to reload the ad zone.
393
+ const timerMs = immediateRefresh
394
+ ? 0
395
+ : this.sessionInfo!.polling_interval_ms >= 300000
396
+ ? this.sessionInfo!.polling_interval_ms
397
+ : 300000;
515
398
 
516
399
  this.refreshAdZonesTimer = setTimeout(() => {
517
400
  adadaptedApiRequests
@@ -520,16 +403,23 @@ export class AdadaptedReactNativeSdk {
520
403
  aid: this.appId,
521
404
  sid: this.sessionId!,
522
405
  uid: this.deviceInfo!.udid,
406
+ sdkVersion: packageJson.version,
407
+ adContext: this.adContext,
523
408
  },
524
409
  this.deviceOs!,
525
410
  this.apiEnv
526
411
  )
527
412
  .then((response) => {
528
413
  this.sessionInfo = response.data;
414
+
415
+ if (this.offScreenAdZones.length > 0) {
416
+ this.offScreenAdZones = this.generateAdZones(
417
+ response.data.zones,
418
+ true
419
+ );
420
+ }
421
+
529
422
  this.adZones = this.generateAdZones(response.data.zones);
530
- this.offScreenAdZones = this.generateOffScreenAdZones(
531
- response.data.zones
532
- );
533
423
 
534
424
  // Call the user defined callback indicating
535
425
  // the session data has been refreshed.
@@ -734,7 +624,6 @@ export class AdadaptedReactNativeSdk {
734
624
  * @param isVisible - Ad Zone visibility tracking.
735
625
  */
736
626
  public onAdZoneVisibilityChanged(isVisible: boolean): void {
737
- this.isAdZoneVisible = isVisible;
738
627
  DeviceEventEmitter.emit("visibility-event", isVisible);
739
628
  }
740
629
 
@@ -760,19 +649,20 @@ export class AdadaptedReactNativeSdk {
760
649
  if (props.apiEnv) {
761
650
  this.apiEnv = props.apiEnv;
762
651
  } else {
763
- this.apiEnv = ApiEnv.Prod;
652
+ this.apiEnv = EnvironmentTypes.ApiEnv.Prod;
764
653
  }
765
654
 
766
655
  // Base the List Manager API environment off what
767
656
  // the user provides for the props.apiEnv value.
768
657
  if (props.apiEnv) {
769
- if (props.apiEnv === ApiEnv.Prod) {
770
- this.listManagerApiEnv = ListManagerApiEnv.Prod;
658
+ if (props.apiEnv === EnvironmentTypes.ApiEnv.Prod) {
659
+ this.listManagerApiEnv =
660
+ EnvironmentTypes.ListManagerApiEnv.Prod;
771
661
  } else {
772
- this.listManagerApiEnv = ListManagerApiEnv.Dev;
662
+ this.listManagerApiEnv = EnvironmentTypes.ListManagerApiEnv.Dev;
773
663
  }
774
664
  } else {
775
- this.listManagerApiEnv = ListManagerApiEnv.Prod;
665
+ this.listManagerApiEnv = EnvironmentTypes.ListManagerApiEnv.Prod;
776
666
  }
777
667
 
778
668
  // The ad zone touch drag sensitivity setting.
@@ -799,21 +689,22 @@ export class AdadaptedReactNativeSdk {
799
689
  }
800
690
 
801
691
  // If provided set any off-screen ad zones.
802
- if (props.offScreenAdZone) {
803
- this.offScreenAdZone = props.offScreenAdZone;
692
+ if ((props.offScreenAdZoneIds ?? []).length > 0) {
693
+ this.offScreenAdZoneIds = props.offScreenAdZoneIds ?? [];
804
694
  }
805
695
 
806
696
  return new Promise<void>((resolve, reject) => {
807
697
  this.getDeviceInformation()
808
698
  .then((deviceInfoObj) => {
809
- const deviceInfo = JSON.parse(deviceInfoObj) as DeviceInfo;
699
+ const deviceInfo = JSON.parse(
700
+ deviceInfoObj
701
+ ) as DeviceTypes.DeviceInfo;
810
702
  this.deviceInfo = deviceInfo;
811
- this.deviceOs =
812
- deviceInfo.systemName === "ios"
813
- ? DeviceOS.IOS
814
- : DeviceOS.ANDROID;
703
+ this.deviceOs = deviceInfo.systemName.includes("ios")
704
+ ? DeviceTypes.DeviceOS.IOS
705
+ : DeviceTypes.DeviceOS.ANDROID;
815
706
  // Pass custom advertiserId - ios only
816
- if (Platform.OS === "ios") {
707
+ if (Platform.OS.includes("ios")) {
817
708
  if (!(props.advertiserId === undefined)) {
818
709
  deviceInfo.udid = props.advertiserId;
819
710
  }
@@ -855,13 +746,17 @@ export class AdadaptedReactNativeSdk {
855
746
  );
856
747
  this.sessionId = response.data.session_id;
857
748
  this.sessionInfo = response.data;
749
+
858
750
  this.adZones = this.generateAdZones(
859
751
  response.data.zones
860
752
  );
861
- this.offScreenAdZones =
862
- this.generateOffScreenAdZones(
863
- response.data.zones
753
+
754
+ if ((props.offScreenAdZoneIds ?? []).length > 0) {
755
+ this.offScreenAdZones = this.generateAdZones(
756
+ response.data.zones,
757
+ true
864
758
  );
759
+ }
865
760
 
866
761
  // Start the session data refresh timer.
867
762
  this.onRefreshAdZones();
@@ -924,8 +819,14 @@ export class AdadaptedReactNativeSdk {
924
819
 
925
820
  this.keywordInterceptSearchValue = searchTerm;
926
821
 
927
- if (!this.deviceInfo || !this.sessionId) {
928
- console.error("AdAdapted SDK has not been initialized.");
822
+ if (!this.deviceInfo) {
823
+ console.error(
824
+ "AdAdapted SDK has not been initialized with device info."
825
+ );
826
+ } else if (!this.sessionId) {
827
+ console.error(
828
+ "AdAdapted SDK has not been initialized with session id."
829
+ );
929
830
  } else if (!this.keywordIntercepts) {
930
831
  console.error("No available keyword intercepts.");
931
832
  } else if (
@@ -1017,8 +918,14 @@ export class AdadaptedReactNativeSdk {
1017
918
  public reportKeywordInterceptTermSelected(termId: string): void {
1018
919
  const termObj = this.getKeywordInterceptTerm(termId);
1019
920
 
1020
- if (!this.deviceInfo || !this.sessionId) {
1021
- console.error("AdAdapted SDK has not been initialized.");
921
+ if (!this.deviceInfo) {
922
+ console.error(
923
+ "AdAdapted SDK has not been initialized with device info."
924
+ );
925
+ } else if (!this.sessionId) {
926
+ console.error(
927
+ "AdAdapted SDK has not been initialized with session id."
928
+ );
1022
929
  } else if (!this.keywordIntercepts) {
1023
930
  console.error("No available keyword intercepts.");
1024
931
  } else if (!termId || !termObj) {
@@ -1070,8 +977,14 @@ export class AdadaptedReactNativeSdk {
1070
977
  }
1071
978
  }
1072
979
 
1073
- if (!this.deviceInfo || !this.sessionId) {
1074
- console.error("AdAdapted SDK has not been initialized.");
980
+ if (!this.deviceInfo) {
981
+ console.error(
982
+ "AdAdapted SDK has not been initialized with device info."
983
+ );
984
+ } else if (!this.sessionId) {
985
+ console.error(
986
+ "AdAdapted SDK has not been initialized with session id."
987
+ );
1075
988
  } else if (!this.keywordIntercepts) {
1076
989
  console.error("No available keyword intercepts.");
1077
990
  } else if (!termIds || termIds.length === 0 || termObjs.length === 0) {
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../example/index.tsx"],"names":[],"mappings":""}
@@ -1,29 +0,0 @@
1
- /**
2
- * Test app component for testing the
3
- * {@link AdadaptedReactNativeSdk} package/module.
4
- */
5
- import React from "react";
6
- import { KeywordSearchResult } from "../../src/index";
7
- /**
8
- * Interfaced used to pass in an item to the {@link StandardAdZonePage.selectItem} method.
9
- * Only one of the two properties should be provided.
10
- */
11
- export interface SelectedItem {
12
- /**
13
- * The object containing a keyword search item.
14
- */
15
- item?: KeywordSearchResult;
16
- /**
17
- * A standard product name.
18
- */
19
- itemName?: string;
20
- }
21
- export type RootStackParamList = {
22
- StandardAdZone: undefined;
23
- OffScreenAdZone: undefined;
24
- };
25
- /**
26
- * Creates the main component for the App.
27
- */
28
- export declare const App: () => React.JSX.Element;
29
- //# sourceMappingURL=App.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../../../example/src/App.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAkB,MAAM,OAAO,CAAC;AAEvC,OAAO,EAIH,mBAAmB,EACtB,MAAM,iBAAiB,CAAC;AAMzB;;;GAGG;AACH,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC7B,cAAc,EAAE,SAAS,CAAC;IAC1B,eAAe,EAAE,SAAS,CAAC;CAC9B,CAAC;AAIF;;GAEG;AACH,eAAO,MAAM,GAAG,yBAyIf,CAAC"}