CheckFeature API
CheckFeature API
checkFeature(options)
Checks in advance whether a specific API is supported on the current platform. APIs that do not exist in the SDK fail immediately without platform communication.
Options:
| Parameter | Type | Required | Description |
|---|---|---|---|
apiName | string | ✅ | Name of the API to check |
success | function | - | Callback when the feature is supported |
fail | function | - | Callback when the feature is unsupported |
complete | function | - | Completion callback |
Success Response:
| Field | Type | Description |
|---|---|---|
supported | true | Feature is supported |
status | 'supported' | Support status |
apiName | string | Name of the checked API |
Failure Response:
| Field | Type | Description |
|---|---|---|
supported | false | Feature is not supported |
status | string | Reason for lack of support |
apiName | string | Name of the checked API |
detail | string? | Detailed description |
status Values:
| Value | Description |
|---|---|
'unknown_api' | API does not exist in the SDK |
'version_required' | App version update required |
'platform_unsupported' | Platform not supported |
'device_unsupported' | Device not supported |
'permission_denied' | Permission denied |
TudadaSDK.checkFeature({
apiName: 'startAccelerometerSensor',
success: (res) => {
console.log('Supported:', res.apiName);
},
fail: (res) => {
console.log('Unsupported:', res.status);
if (res.status === 'version_required') {
showUpdatePrompt(); // Show in-game update prompt
}
},
});
checkFeatureAsync(apiName)
Promise-based feature check. Both supported and unsupported results are returned via resolve.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
apiName | string | ✅ | Name of the API to check |
Return Value:
| Field | Type | Description |
|---|---|---|
supported | boolean | Whether the feature is supported |
status | string | Support status or reason for lack of support |
apiName | string | Name of the checked API |
detail | string? | Detailed description (when unsupported) |
const result = await TudadaSDK.checkFeatureAsync('startAccelerometerSensor');
if (result.supported) {
TudadaSDK.startAccelerometerSensor();
} else {
console.log('Unsupported reason:', result.status);
}