@globules-io/cordova-plugin-apple-age-check 0.1.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.
- package/LICENSE +21 -0
- package/README.md +53 -0
- package/package.json +26 -0
- package/plugin.xml +26 -0
- package/src/ios/AgeCheckPlugin.swift +59 -0
- package/www/AgeCheck.js +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 globules.io
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# cordova-plugin-apple-age-check
|
|
2
|
+
|
|
3
|
+
iOS plugin for **Apple's Declared Age Range API** (iOS 26+).
|
|
4
|
+
|
|
5
|
+
This plugin provides a simple Cordova interface to request the user's declared age range on iOS.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Uses Apple's official `DeclaredAgeRange` framework
|
|
10
|
+
- Returns normalized result format (consistent with Android version)
|
|
11
|
+
- Includes `isSupported()` check
|
|
12
|
+
- Lightweight and async-friendly
|
|
13
|
+
|
|
14
|
+
## Requirements
|
|
15
|
+
|
|
16
|
+
- Cordova iOS platform ≥ 7.0.0
|
|
17
|
+
- iOS 26 or later
|
|
18
|
+
- The entitlement **`com.apple.developer.declared-age-range`** must be enabled in your Xcode project
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
cordova plugin add @globules-io/cordova-plugin-apple-age-check
|
|
25
|
+
cordova plugin rm @globules-io/cordova-plugin-apple-age-check
|
|
26
|
+
```
|
|
27
|
+
## Supported Platforms
|
|
28
|
+
|
|
29
|
+
iOS (26+)
|
|
30
|
+
|
|
31
|
+
## JS API
|
|
32
|
+
```bash
|
|
33
|
+
AgeCheckPlugin.checkAge(
|
|
34
|
+
function(result) {
|
|
35
|
+
console.log("Apple Age Check Result:", result);
|
|
36
|
+
|
|
37
|
+
if (result.userStatus === "DECLARED") {
|
|
38
|
+
console.log(`Age range: ${result.ageLower} - ${result.ageUpper}`);
|
|
39
|
+
// Grant appropriate access based on age
|
|
40
|
+
}
|
|
41
|
+
else if (result.userStatus === "DECLINED") {
|
|
42
|
+
// User declined to share age → apply restricted experience
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
function(error) {
|
|
46
|
+
console.error("Age check failed:", error);
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
AgeCheckPlugin.isSupported(function(supported) {
|
|
51
|
+
console.log("Declared Age Range API supported:", supported);
|
|
52
|
+
});
|
|
53
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@globules-io/cordova-plugin-apple-age-check",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "iOS Age Check using Apple's Declared Age Range API",
|
|
5
|
+
"cordova": {
|
|
6
|
+
"id": "@globules-io/cordova-plugin-apple-age-check",
|
|
7
|
+
"platforms": [
|
|
8
|
+
"ios"
|
|
9
|
+
]
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"cordova",
|
|
13
|
+
"ios",
|
|
14
|
+
"age",
|
|
15
|
+
"verification"
|
|
16
|
+
],
|
|
17
|
+
"author": "globules.io",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/globules-io/cordova-plugin-apple-age-check.git"
|
|
22
|
+
},
|
|
23
|
+
"engines": {
|
|
24
|
+
"cordova": ">=10.0.0"
|
|
25
|
+
}
|
|
26
|
+
}
|
package/plugin.xml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
3
|
+
id="@globules-io/cordova-plugin-apple-age-check"
|
|
4
|
+
version="0.1.0">
|
|
5
|
+
<name>Apple Age Check</name>
|
|
6
|
+
<description>iOS implementation for Apple's Declared Age Range API (iOS 26+). Returns normalized age signals.</description>
|
|
7
|
+
<license>MIT</license>
|
|
8
|
+
<keywords>cordova,ios,age,verification,declared,age-range</keywords>
|
|
9
|
+
<author email="info@globules.io">globules.io</author>
|
|
10
|
+
<repository url="https://github.com/globules-io/cordova-plugin-apple-age-check.git" />
|
|
11
|
+
<engines>
|
|
12
|
+
<engine name="cordova" version=">=10.0.0" />
|
|
13
|
+
<engine name="cordova-ios" version=">=7.0.0" />
|
|
14
|
+
</engines>
|
|
15
|
+
<platform name="ios">
|
|
16
|
+
<source-file src="src/ios/AgeCheckPlugin.swift" />
|
|
17
|
+
<config-file target="config.xml" parent="/widget">
|
|
18
|
+
<feature name="AgeCheck">
|
|
19
|
+
<param name="ios-package" value="AgeCheckPlugin" />
|
|
20
|
+
</feature>
|
|
21
|
+
</config-file>
|
|
22
|
+
</platform>
|
|
23
|
+
<js-module src="www/AgeCheck.js" name="AgeCheckPlugin">
|
|
24
|
+
<clobbers target="AgeCheckPlugin" />
|
|
25
|
+
</js-module>
|
|
26
|
+
</plugin>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import Cordova
|
|
2
|
+
import DeclaredAgeRange
|
|
3
|
+
|
|
4
|
+
@objc(AgeCheckPlugin)
|
|
5
|
+
class AgeCheckPlugin: CDVPlugin {
|
|
6
|
+
|
|
7
|
+
@objc(checkAge:)
|
|
8
|
+
func checkAge(command: CDVInvokedUrlCommand) {
|
|
9
|
+
// Guard for iOS 26+
|
|
10
|
+
guard #available(iOS 26.0, *) else {
|
|
11
|
+
let pluginResult = CDVPluginResult(status: .error,
|
|
12
|
+
messageAs: "Declared Age Range API requires iOS 26 or later")
|
|
13
|
+
self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
|
|
14
|
+
return
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
Task { @MainActor in
|
|
18
|
+
do {
|
|
19
|
+
// Request with age gate (you can pass array like [13, 16, 18] for finer control)
|
|
20
|
+
let response = try await AgeRangeService.shared.requestAgeRange(ageGates: 18)
|
|
21
|
+
|
|
22
|
+
var result: [String: Any] = [:]
|
|
23
|
+
|
|
24
|
+
switch response {
|
|
25
|
+
case .sharing(let ageRange):
|
|
26
|
+
result["userStatus"] = "DECLARED" // Normalized to match Android
|
|
27
|
+
result["ageLower"] = ageRange.lowerBound ?? NSNull()
|
|
28
|
+
result["ageUpper"] = ageRange.upperBound ?? NSNull()
|
|
29
|
+
result["mostRecentApprovalDate"] = NSNull() // Not available on iOS
|
|
30
|
+
result["installId"] = NSNull() // Not available on iOS
|
|
31
|
+
|
|
32
|
+
case .declinedSharing:
|
|
33
|
+
result["userStatus"] = "DECLINED"
|
|
34
|
+
result["ageLower"] = NSNull()
|
|
35
|
+
result["ageUpper"] = NSNull()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let pluginResult = CDVPluginResult(status: .ok, messageAs: result)
|
|
39
|
+
self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
|
|
40
|
+
|
|
41
|
+
} catch let error as AgeRangeService.Error {
|
|
42
|
+
let errorMsg = "AgeRangeService error: \(error)"
|
|
43
|
+
let pluginResult = CDVPluginResult(status: .error, messageAs: errorMsg)
|
|
44
|
+
self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
|
|
45
|
+
} catch {
|
|
46
|
+
let pluginResult = CDVPluginResult(status: .error,
|
|
47
|
+
messageAs: "Unknown error: \(error.localizedDescription)")
|
|
48
|
+
self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@objc(isSupported:)
|
|
54
|
+
func isSupported(command: CDVInvokedUrlCommand) {
|
|
55
|
+
let supported = #available(iOS 26.0, *) && AgeRangeService.isSupported
|
|
56
|
+
let pluginResult = CDVPluginResult(status: .ok, messageAs: supported ? 1 : 0)
|
|
57
|
+
self.commandDelegate.send(pluginResult, callbackId: command.callbackId)
|
|
58
|
+
}
|
|
59
|
+
}
|
package/www/AgeCheck.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var exec = require('cordova/exec');
|
|
2
|
+
var AgeCheckPlugin = {};
|
|
3
|
+
/**
|
|
4
|
+
* Check the user's age verification status using Apple's Declared Age Range API.
|
|
5
|
+
*
|
|
6
|
+
* @param {function} successCallback - Called with result object on success
|
|
7
|
+
* @param {function} errorCallback - Called with error on failure
|
|
8
|
+
*
|
|
9
|
+
* Result object example:
|
|
10
|
+
* {
|
|
11
|
+
* "userStatus": "DECLARED" | "DECLINED" | null,
|
|
12
|
+
* "ageLower": number | null,
|
|
13
|
+
* "ageUpper": number | null,
|
|
14
|
+
* "mostRecentApprovalDate": null, // Not available on iOS
|
|
15
|
+
* "installId": null // Not available on iOS
|
|
16
|
+
* }
|
|
17
|
+
*/
|
|
18
|
+
AgeCheckPlugin.checkAge = function(successCallback, errorCallback) {
|
|
19
|
+
if (typeof successCallback !== 'function') {
|
|
20
|
+
console.warn('AgeCheckPlugin.checkAge: successCallback must be a function');
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (typeof errorCallback !== 'function') {
|
|
24
|
+
errorCallback = function(err) {
|
|
25
|
+
console.error('AgeCheckPlugin.checkAge error:', err);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
exec(
|
|
29
|
+
successCallback,
|
|
30
|
+
errorCallback,
|
|
31
|
+
'AgeCheck',
|
|
32
|
+
'checkAge',
|
|
33
|
+
[]
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Check if the Declared Age Range API is supported on this device.
|
|
39
|
+
*
|
|
40
|
+
* @param {function} successCallback - Called with boolean (true/false)
|
|
41
|
+
* @param {function} errorCallback - Optional
|
|
42
|
+
*/
|
|
43
|
+
AgeCheckPlugin.isSupported = function(successCallback, errorCallback) {
|
|
44
|
+
if (typeof successCallback !== 'function') {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (typeof errorCallback !== 'function') {
|
|
49
|
+
errorCallback = function() {};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
exec(
|
|
53
|
+
successCallback,
|
|
54
|
+
errorCallback,
|
|
55
|
+
'AgeCheck',
|
|
56
|
+
'isSupported',
|
|
57
|
+
[]
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
module.exports = AgeCheckPlugin;
|