setupSha method
Orchestrates the full SHA setup flow for the specified projectId.
This includes:
- Fetching SHA-1 and SHA-256 values locally.
- Finding the corresponding Firebase Android App ID.
- Uploading both fingerprints to the Firebase Console.
Implementation
Future<void> setupSha(String projectId) async {
print('š Setting up SHA (SHA-1 + SHA-256)...\n');
final shas = await getShas();
final sha1 = shas['sha1'];
final sha256 = shas['sha256'];
if ((sha1 == null || sha1.isEmpty) &&
(sha256 == null || sha256.isEmpty)) {
print('ā No SHA values found');
return;
}
final appId = await getAndroidAppId(projectId);
if (appId == null) {
print('ā Android app not found in Firebase');
return;
}
/// š¹ Upload SHA-1
if (sha1 != null && sha1.isNotEmpty) {
print('š Adding SHA-1...');
await run('firebase', [
'apps:android:sha:create',
appId,
sha1,
'--project=$projectId',
]);
}
/// š¹ Upload SHA-256
if (sha256 != null && sha256.isNotEmpty) {
print('š Adding SHA-256...');
await run('firebase', [
'apps:android:sha:create',
appId,
sha256,
'--project=$projectId',
]);
}
print('\nš SHA-1 & SHA-256 added successfully');
}