@milkinteractive/react-native-age-range 1.0.4 → 1.0.6
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 +125 -0
- package/ios/StoreAgeSignalsNativeModules.mm +37 -10
- package/ios/StoreAgeSignalsNativeModules.swift +237 -11
- package/lib/commonjs/index.js +186 -5
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +183 -5
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/index.d.ts +142 -5
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.tsx +221 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAqBA;;;;;;;GAOG;AACH,MAAM,MAAM,iBAAiB,GACzB,UAAU,GACV,WAAW,GACX,4BAA4B,GAC5B,2BAA2B,GAC3B,SAAS,CAAC;AAEd,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACrC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAID;;;;;;;;;;GAUG;AACH,MAAM,MAAM,uBAAuB,GAC/B,cAAc,GACd,kBAAkB,GAClB,sBAAsB,GACtB,8BAA8B,GAC9B,qBAAqB,GACrB,6BAA6B,GAC7B,gBAAgB,GAChB,wBAAwB,GACxB,SAAS,CAAC;AAEd;;GAEG;AACH,MAAM,WAAW,oBA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AKD;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,iBAAiB,EAAE,MAAM,EACzB,kBAAkB,CAAC,EAAE,MAAM,EAC3B,iBAAiB,CAAC,EAAE,MAAM,GACzB,OAAO,CAAC,sBAAsB,CAAC,CA8BjC;AAKD;;;;;;GAMG;AACH,wBAAgB,2BAA2B,IAAI,OAAO,CAAC,4BAA4B,CAAC,CAkBnF;AAED;;;;;;GAMG;AACH,wBAAgB,+BAA+B,IAAI,OAAO,CAAC,4BAA4B,CAAC,CAQvF;AAID;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,mCAAmC,IAAI,OAAO,CAAC,uBAAuB,CAAC,CAQtF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,oBAAoB,EAAE,EAChC,OAAO,CAAC,EAAE,mBAAmB,EAAE,GAC9B,OAAO,CAAC,6BAA6B,CAAC,CAWxC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,oBAAoB,EAAE,GAC9B,OAAO,CAAC,kBAAkB,CAAC,CAQ7B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milkinteractive/react-native-age-range",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "A React Native Native Module (Legacy Architecture) that provides access to store-level age signals, including Android Play Age Range and iOS Declared Age, to assist with state-level age verification compliance (e.g., Texas).",
|
|
5
5
|
"source": "./src/index.tsx",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"type": "git",
|
|
64
64
|
"url": "git+https://github.com/valleyelectronics/react-native-age-range.git"
|
|
65
65
|
},
|
|
66
|
-
"author": "
|
|
66
|
+
"author": "Naga sai charan gubba <nagasaicharan7@gmail.com> (https://github.com/nagasaicharan)",
|
|
67
67
|
"contributors": [
|
|
68
68
|
"Christoph Eck <christoph@milkinteractive.ch>"
|
|
69
69
|
],
|
package/src/index.tsx
CHANGED
|
@@ -119,6 +119,70 @@ export interface DeclaredAgeEligibilityResult {
|
|
|
119
119
|
error: string | null;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
// ========== PERMISSIONKIT TYPES (iOS 26+) ==========
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Status of significant change approval request.
|
|
126
|
+
* - approved: Parent/guardian approved the change
|
|
127
|
+
* - denied: Parent/guardian denied the change
|
|
128
|
+
* - pending: Request has been sent, awaiting response
|
|
129
|
+
*/
|
|
130
|
+
export type SignificantChangeStatus = 'approved' | 'denied' | 'pending' | null;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Result of significant change approval request.
|
|
134
|
+
*/
|
|
135
|
+
export interface SignificantChangeResult {
|
|
136
|
+
status: SignificantChangeStatus;
|
|
137
|
+
error: string | null;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Handle type for communication contacts.
|
|
142
|
+
* - phoneNumber: Phone number identifier
|
|
143
|
+
* - email: Email address identifier
|
|
144
|
+
* - custom: Custom identifier (username, handle, etc.)
|
|
145
|
+
*/
|
|
146
|
+
export type CommunicationHandleKind = 'phoneNumber' | 'email' | 'custom';
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Contact information for communication permission request.
|
|
150
|
+
*/
|
|
151
|
+
export interface CommunicationContact {
|
|
152
|
+
/** Unique identifier (phone, email, username) */
|
|
153
|
+
handle: string;
|
|
154
|
+
/** Type of handle */
|
|
155
|
+
handleKind: CommunicationHandleKind;
|
|
156
|
+
/** Optional display name shown to parent/guardian */
|
|
157
|
+
displayName?: string;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Communication actions that can be requested.
|
|
162
|
+
* - message: Text/chat messaging
|
|
163
|
+
* - call: Voice calls
|
|
164
|
+
* - video: Video calls
|
|
165
|
+
*/
|
|
166
|
+
export type CommunicationAction = 'message' | 'call' | 'video';
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Result of communication permission request.
|
|
170
|
+
*/
|
|
171
|
+
export interface CommunicationPermissionResult {
|
|
172
|
+
/** Whether the permission request was successfully shown */
|
|
173
|
+
granted: boolean;
|
|
174
|
+
error: string | null;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Result of known handles check.
|
|
179
|
+
*/
|
|
180
|
+
export interface KnownHandlesResult {
|
|
181
|
+
/** Handles that are recognized by the system (known contacts) */
|
|
182
|
+
knownHandles: string[];
|
|
183
|
+
error: string | null;
|
|
184
|
+
}
|
|
185
|
+
|
|
122
186
|
export interface AndroidAgeRangeConfig {
|
|
123
187
|
/**
|
|
124
188
|
* Enable mock mode to simulate results without calling Google Play API.
|
|
@@ -170,17 +234,21 @@ export function getAndroidPlayAgeRangeStatus(
|
|
|
170
234
|
);
|
|
171
235
|
}
|
|
172
236
|
|
|
237
|
+
// Minimum iOS version required for DeclaredAgeRange API
|
|
238
|
+
const IOS_MIN_VERSION_DECLARED_AGE_RANGE = 26;
|
|
239
|
+
|
|
173
240
|
/**
|
|
174
241
|
* Requests age range declaration from iOS Declared Age Range API.
|
|
175
242
|
* @platform ios
|
|
176
|
-
* @param firstThresholdAge First age threshold (e.g., 13)
|
|
177
|
-
* @param secondThresholdAge Second age threshold (e.g., 17)
|
|
178
|
-
* @param thirdThresholdAge Third age threshold (e.g., 21)
|
|
243
|
+
* @param firstThresholdAge First age threshold (required, e.g., 13)
|
|
244
|
+
* @param secondThresholdAge Second age threshold (optional, e.g., 17)
|
|
245
|
+
* @param thirdThresholdAge Third age threshold (optional, e.g., 21)
|
|
246
|
+
* @remarks Requires iOS 26.0+. Returns error on older iOS versions.
|
|
179
247
|
*/
|
|
180
248
|
export function requestIOSDeclaredAgeRange(
|
|
181
249
|
firstThresholdAge: number,
|
|
182
|
-
secondThresholdAge
|
|
183
|
-
thirdThresholdAge
|
|
250
|
+
secondThresholdAge?: number,
|
|
251
|
+
thirdThresholdAge?: number
|
|
184
252
|
): Promise<DeclaredAgeRangeResult> {
|
|
185
253
|
if (Platform.OS !== 'ios') {
|
|
186
254
|
return Promise.resolve({
|
|
@@ -192,19 +260,36 @@ export function requestIOSDeclaredAgeRange(
|
|
|
192
260
|
error: 'This method is only available on iOS',
|
|
193
261
|
});
|
|
194
262
|
}
|
|
263
|
+
|
|
264
|
+
// Early return for iOS versions below 26 to prevent native bridge errors
|
|
265
|
+
const iosVersion = parseInt(String(Platform.Version), 10);
|
|
266
|
+
if (iosVersion < IOS_MIN_VERSION_DECLARED_AGE_RANGE) {
|
|
267
|
+
return Promise.resolve({
|
|
268
|
+
status: null,
|
|
269
|
+
lowerBound: null,
|
|
270
|
+
upperBound: null,
|
|
271
|
+
ageRangeDeclaration: null,
|
|
272
|
+
parentalControls: null,
|
|
273
|
+
error: `Requires iOS ${IOS_MIN_VERSION_DECLARED_AGE_RANGE}.0+. Current version: iOS ${iosVersion}`,
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
|
|
195
277
|
return StoreAgeSignalsNativeModules.requestIOSDeclaredAgeRange(
|
|
196
278
|
firstThresholdAge,
|
|
197
|
-
secondThresholdAge,
|
|
198
|
-
thirdThresholdAge
|
|
279
|
+
secondThresholdAge ?? null,
|
|
280
|
+
thirdThresholdAge ?? null
|
|
199
281
|
);
|
|
200
282
|
}
|
|
201
283
|
|
|
284
|
+
// Minimum iOS version required for isEligibleForAgeFeatures API
|
|
285
|
+
const IOS_MIN_VERSION_ELIGIBLE_CHECK = 26;
|
|
286
|
+
|
|
202
287
|
/**
|
|
203
288
|
* Checks if the current user is eligible for age verification features on iOS.
|
|
204
289
|
* This determines if age checks need to be applied (e.g., user is in an applicable region like Texas).
|
|
205
290
|
* @platform ios
|
|
206
291
|
* @returns Promise<DeclaredAgeEligibilityResult> - Object containing isEligible boolean and error string
|
|
207
|
-
* @remarks Requires iOS 26.
|
|
292
|
+
* @remarks Requires iOS 26.2+. Returns isEligible: false with error message if not available.
|
|
208
293
|
*/
|
|
209
294
|
export function isIOSEligibleForAgeFeatures(): Promise<DeclaredAgeEligibilityResult> {
|
|
210
295
|
if (Platform.OS !== 'ios') {
|
|
@@ -213,6 +298,16 @@ export function isIOSEligibleForAgeFeatures(): Promise<DeclaredAgeEligibilityRes
|
|
|
213
298
|
error: 'This method is only available on iOS',
|
|
214
299
|
});
|
|
215
300
|
}
|
|
301
|
+
|
|
302
|
+
// Early return for iOS versions below 26 to prevent native bridge errors
|
|
303
|
+
const iosVersion = parseInt(String(Platform.Version), 10);
|
|
304
|
+
if (iosVersion < IOS_MIN_VERSION_ELIGIBLE_CHECK) {
|
|
305
|
+
return Promise.resolve({
|
|
306
|
+
isEligible: false,
|
|
307
|
+
error: `Requires iOS ${IOS_MIN_VERSION_ELIGIBLE_CHECK}.0+. Current version: iOS ${iosVersion}`,
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
|
|
216
311
|
return StoreAgeSignalsNativeModules.isEligibleForAgeFeatures();
|
|
217
312
|
}
|
|
218
313
|
|
|
@@ -232,3 +327,121 @@ export function isAndroidEligibleForAgeFeatures(): Promise<DeclaredAgeEligibilit
|
|
|
232
327
|
}
|
|
233
328
|
return StoreAgeSignalsNativeModules.isEligibleForAgeFeatures();
|
|
234
329
|
}
|
|
330
|
+
|
|
331
|
+
// ========== PERMISSIONKIT FUNCTIONS (iOS 26+) ==========
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Requests parental approval for significant app changes (iOS PermissionKit).
|
|
335
|
+
*
|
|
336
|
+
* Use this when `parentalControls.significantAppChangeApprovalRequired` is `true`
|
|
337
|
+
* from the `requestIOSDeclaredAgeRange()` response.
|
|
338
|
+
*
|
|
339
|
+
* This shows a system dialog to request parental consent for significant app updates.
|
|
340
|
+
* The parent/guardian will receive a notification via Messages.
|
|
341
|
+
*
|
|
342
|
+
* @platform ios
|
|
343
|
+
* @requires iOS 26.0+
|
|
344
|
+
* @returns Promise<SignificantChangeResult> - Contains status ('pending', 'approved', 'denied') and error
|
|
345
|
+
*
|
|
346
|
+
* @example
|
|
347
|
+
* ```typescript
|
|
348
|
+
* const ageResult = await requestIOSDeclaredAgeRange(13, 17, 21);
|
|
349
|
+
* if (ageResult.parentalControls?.significantAppChangeApprovalRequired) {
|
|
350
|
+
* const result = await requestIOSSignificantChangeApproval();
|
|
351
|
+
* if (result.status === 'pending') {
|
|
352
|
+
* // Request sent, await parent response
|
|
353
|
+
* }
|
|
354
|
+
* }
|
|
355
|
+
* ```
|
|
356
|
+
*/
|
|
357
|
+
export function requestIOSSignificantChangeApproval(): Promise<SignificantChangeResult> {
|
|
358
|
+
if (Platform.OS !== 'ios') {
|
|
359
|
+
return Promise.resolve({
|
|
360
|
+
status: null,
|
|
361
|
+
error: 'This method is only available on iOS',
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
return StoreAgeSignalsNativeModules.requestSignificantChangeApproval();
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Requests permission for a child to communicate with specified contacts (iOS PermissionKit).
|
|
369
|
+
*
|
|
370
|
+
* Use this when `parentalControls.communicationLimits` is `true`
|
|
371
|
+
* from the `requestIOSDeclaredAgeRange()` response.
|
|
372
|
+
*
|
|
373
|
+
* This shows a system dialog requesting the parent/guardian to approve
|
|
374
|
+
* communication with the specified contacts. The request is sent via Messages.
|
|
375
|
+
*
|
|
376
|
+
* @platform ios
|
|
377
|
+
* @requires iOS 26.2+
|
|
378
|
+
* @param contacts - Array of contacts to request permission for
|
|
379
|
+
* @param actions - Optional array of communication actions (defaults to ['message'])
|
|
380
|
+
* @returns Promise<CommunicationPermissionResult> - Contains granted boolean and error
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* ```typescript
|
|
384
|
+
* const ageResult = await requestIOSDeclaredAgeRange(13, 17, 21);
|
|
385
|
+
* if (ageResult.parentalControls?.communicationLimits) {
|
|
386
|
+
* const result = await requestIOSCommunicationPermission(
|
|
387
|
+
* [{ handle: 'friend@example.com', handleKind: 'email', displayName: 'School Friend' }],
|
|
388
|
+
* ['message', 'call']
|
|
389
|
+
* );
|
|
390
|
+
* }
|
|
391
|
+
* ```
|
|
392
|
+
*/
|
|
393
|
+
export function requestIOSCommunicationPermission(
|
|
394
|
+
contacts: CommunicationContact[],
|
|
395
|
+
actions?: CommunicationAction[]
|
|
396
|
+
): Promise<CommunicationPermissionResult> {
|
|
397
|
+
if (Platform.OS !== 'ios') {
|
|
398
|
+
return Promise.resolve({
|
|
399
|
+
granted: false,
|
|
400
|
+
error: 'This method is only available on iOS',
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
return StoreAgeSignalsNativeModules.requestCommunicationPermission(
|
|
404
|
+
contacts,
|
|
405
|
+
actions || ['message']
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Checks which handles are recognized by the system (known contacts) (iOS PermissionKit).
|
|
411
|
+
*
|
|
412
|
+
* Use this to determine which contacts are already approved before showing
|
|
413
|
+
* a communication permission request.
|
|
414
|
+
*
|
|
415
|
+
* @platform ios
|
|
416
|
+
* @requires iOS 26.2+
|
|
417
|
+
* @param handles - Array of handles to check
|
|
418
|
+
* @returns Promise<KnownHandlesResult> - Contains array of known handle values and error
|
|
419
|
+
*
|
|
420
|
+
* @example
|
|
421
|
+
* ```typescript
|
|
422
|
+
* const result = await getIOSKnownCommunicationHandles([
|
|
423
|
+
* { handle: 'user@example.com', handleKind: 'email' },
|
|
424
|
+
* { handle: 'gamer123', handleKind: 'custom' }
|
|
425
|
+
* ]);
|
|
426
|
+
*
|
|
427
|
+
* const unknownContacts = handles.filter(
|
|
428
|
+
* h => !result.knownHandles.includes(h.handle)
|
|
429
|
+
* );
|
|
430
|
+
*
|
|
431
|
+
* if (unknownContacts.length > 0) {
|
|
432
|
+
* // Request permission for unknown contacts
|
|
433
|
+
* await requestIOSCommunicationPermission(unknownContacts);
|
|
434
|
+
* }
|
|
435
|
+
* ```
|
|
436
|
+
*/
|
|
437
|
+
export function getIOSKnownCommunicationHandles(
|
|
438
|
+
handles: CommunicationContact[]
|
|
439
|
+
): Promise<KnownHandlesResult> {
|
|
440
|
+
if (Platform.OS !== 'ios') {
|
|
441
|
+
return Promise.resolve({
|
|
442
|
+
knownHandles: [],
|
|
443
|
+
error: 'This method is only available on iOS',
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
return StoreAgeSignalsNativeModules.getKnownCommunicationHandles(handles);
|
|
447
|
+
}
|