getAndroidAppId method

Future<String?> getAndroidAppId(
  1. String projectId
)

Retrieves the Android App ID (also known as the App Index) from the specified Firebase projectId.

Returns null if no Android app is found linked to the project.

Implementation

Future<String?> getAndroidAppId(String projectId) async {
  print('🔍 Fetching Android App ID...');

  final result = await runWithResult(
    'firebase',
    ['apps:list', '--project=$projectId'],
  );

  final output = result.stdout.toString();

  final regex = RegExp(r'1:\d+:android:[a-zA-Z0-9]+');
  final match = regex.firstMatch(output);

  if (match != null) {
    final appId = match.group(0);
    print('✅ Android App ID: $appId');
    return appId;
  }

  print('❌ Android App ID not found');
  return null;
}