appleAttestKey method

  1. @override
Future<AppleAttestationResult> appleAttestKey(
  1. String keyId,
  2. String data
)
override

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 use
  • data: Challenge data to include in the attestation

Returns a Future that completes with an AppleAttestationResult containing the attestation statement and related metadata.

Throws:

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!);
}