@chipmobilesdk/rn-ads 0.4.0 → 0.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.
@@ -40,9 +40,19 @@ export const initialPlacement: PlacementSnapshot = {
40
40
  correlationId: null,
41
41
  };
42
42
 
43
- /** A load is only legal from a settled state; `loading` is where FR-029 bites. */
43
+ /**
44
+ * A load is only legal from a settled state; `loading` is where FR-029 bites.
45
+ * `throttled` is settled too: it records that the last request was refused, and
46
+ * the throttle itself decides whether the next one may proceed.
47
+ */
44
48
  export function canLoad(state: PlacementState): boolean {
45
- return state === 'idle' || state === 'failed' || state === 'consumed' || state === 'ready';
49
+ return (
50
+ state === 'idle' ||
51
+ state === 'failed' ||
52
+ state === 'consumed' ||
53
+ state === 'ready' ||
54
+ state === 'throttled'
55
+ );
46
56
  }
47
57
 
48
58
  /** Only a ready ad may be shown. Everything else is a determinate refusal (FR-028). */
@@ -15,7 +15,7 @@
15
15
  */
16
16
 
17
17
  import type { PrivacyBlockReason, PrivacyOptions } from '../config/types';
18
- import type { EnginePrivacy } from '../engine/port';
18
+ import type { EnginePrivacy, EngineRequestOptions } from '../engine/port';
19
19
 
20
20
  export type GateDecision =
21
21
  | { readonly allowed: true }
@@ -83,3 +83,12 @@ export function toEnginePrivacy(
83
83
  testDeviceIds,
84
84
  };
85
85
  }
86
+
87
+ /**
88
+ * What every ad request carries. Unset means personalized, matching the
89
+ * documented default of `PrivacyOptions.personalizedAds`; only an explicit
90
+ * `false` opts out.
91
+ */
92
+ export function toEngineRequest(privacy: PrivacyOptions | null): EngineRequestOptions {
93
+ return { personalizedAds: privacy?.personalizedAds !== false };
94
+ }
@@ -27,6 +27,7 @@ import type {
27
27
  EngineConsentInfo,
28
28
  EngineConsentOptions,
29
29
  EnginePrivacy,
30
+ EngineRequestOptions,
30
31
  } from './port';
31
32
 
32
33
  /** The slice of the bridge this adapter uses. Kept local so nothing else sees it. */
@@ -227,7 +228,11 @@ export function createAdMobEngine(): AdsEngine {
227
228
  await mobileAds.initialize();
228
229
  },
229
230
 
230
- async createFullScreen(format: FullScreenFormat, adUnitId: string) {
231
+ async createFullScreen(
232
+ format: FullScreenFormat,
233
+ adUnitId: string,
234
+ request?: EngineRequestOptions,
235
+ ) {
231
236
  const module = getProvider();
232
237
  if (!module) {
233
238
  throw new Error('provider_missing');
@@ -242,7 +247,7 @@ export function createAdMobEngine(): AdsEngine {
242
247
  const ad = factory.createForAdRequest(adUnitId, {
243
248
  // The consumer-facing polarity is `personalizedAds`; the provider's
244
249
  // is the inverse. The flip lives here, next to the API needing it.
245
- requestNonPersonalizedAdsOnly: false,
250
+ requestNonPersonalizedAdsOnly: request?.personalizedAds === false,
246
251
  });
247
252
 
248
253
  counter += 1;
@@ -23,6 +23,17 @@ export interface EnginePrivacy {
23
23
  readonly testDeviceIds?: readonly string[];
24
24
  }
25
25
 
26
+ /**
27
+ * Privacy that applies to each ad request rather than to initialization.
28
+ *
29
+ * `personalizedAds` is here, not only in `EnginePrivacy`, because the provider
30
+ * reads it per request and `updatePrivacy` may change it without
31
+ * reinitializing: a request must carry the value current at request time.
32
+ */
33
+ export interface EngineRequestOptions {
34
+ readonly personalizedAds: boolean;
35
+ }
36
+
26
37
  /**
27
38
  * Provider callbacks, normalized to the vocabulary the core state machines use.
28
39
  * `rewarded` and `dismissed` are separate members because they are separate
@@ -108,8 +119,16 @@ export interface AdsEngine {
108
119
  */
109
120
  initialize(privacy: EnginePrivacy): Promise<void>;
110
121
 
111
- /** Creates and begins loading one full-screen ad. Resolves on request, not on load. */
112
- createFullScreen(format: FullScreenFormat, adUnitId: string): Promise<EngineAdHandle>;
122
+ /**
123
+ * Creates and begins loading one full-screen ad. Resolves on request, not on
124
+ * load. `request` is optional so engines written against 0.4.0 still satisfy
125
+ * the port; an engine that ignores it requests personalized ads.
126
+ */
127
+ createFullScreen(
128
+ format: FullScreenFormat,
129
+ adUnitId: string,
130
+ request?: EngineRequestOptions,
131
+ ): Promise<EngineAdHandle>;
113
132
 
114
133
  /** Presents a loaded ad. Rejects if the provider refuses to present. */
115
134
  show(handle: EngineAdHandle): Promise<void>;