testAppLink static method
Test opening an app link
Implementation
static Future<VerificationResult> testAppLink(
String url,
String? packageName,
) async {
if (!await isAdbAvailable()) {
return VerificationResult(
checkName: 'Android Runtime Test - App Link',
status: VerificationStatus.skipped,
message: 'ADB not available',
);
}
if (!await isDeviceConnected()) {
return VerificationResult(
checkName: 'Android Runtime Test - App Link',
status: VerificationStatus.skipped,
message: 'No Android device connected',
);
}
try {
final result = await Process.run('adb', [
'shell',
'am',
'start',
'-a',
'android.intent.action.VIEW',
'-c',
'android.intent.category.BROWSABLE',
'-d',
url,
]);
if (result.exitCode == 0) {
return VerificationResult(
checkName: 'Android Runtime Test - App Link',
status: VerificationStatus.success,
message: 'Successfully opened app link',
details: {'url': url},
);
} else {
return VerificationResult(
checkName: 'Android Runtime Test - App Link',
status: VerificationStatus.warning,
message: 'Failed to open app link: ${result.stderr}',
fixSuggestion:
'Ensure the app is installed and app links are configured',
details: {'url': url, 'error': result.stderr},
);
}
} catch (e) {
return VerificationResult(
checkName: 'Android Runtime Test - App Link',
status: VerificationStatus.error,
message: 'Error testing app link: $e',
fixSuggestion: 'Check that ADB is working and device is connected',
);
}
}