appleAttestKey method
Generates an Apple App Attestation for a given key and challenge data.
This method creates an attestation statement for the specified keyId
using the provided data
as challenge material. The attestation proves
that the key was generated in the device's Secure Enclave and validates
the app's authenticity.
Parameters:
keyId
: The identifier of the attestation key to usedata
: Challenge data to include in the attestation
Returns a Future that completes with an AppleAttestationResult containing the attestation statement and related metadata.
Throws:
- PlatformException if the native attestation process fails
- MissingPluginException if the platform implementation is not available
Example:
final result = await device.appleAttestKey(
'key123',
base64Encode(utf8.encode('challenge-data')),
);
print('Attestation: ${result.attestationObject}');
Implementation
@override
Future<AppleAttestationResult> appleAttestKey(
String keyId,
String data,
) async {
final result = await methodChannel.invokeMapMethod<String, dynamic>(
"appleAttestKey",
{"keyId": keyId, "data": data},
);
return AppleAttestationResult.fromJson(result!);
}