Update ClipboardUtility.ts (#1157)

This commit is contained in:
Leendert de Borst
2025-08-29 16:51:08 +02:00
committed by Leendert de Borst
parent fe7da551a4
commit 2c98b81111

View File

@@ -2,13 +2,12 @@ import NativeVaultManager from '@/specs/NativeVaultManager';
/**
* Copy text to clipboard with automatic expiration based on platform capabilities.
*
*
* On iOS: Uses native clipboard expiration via UIPasteboard.setItems with expirationDate.
* On Android: Uses native method that combines clipboard copy with automatic clearing:
* - For delays ≤10 seconds: Uses Handler (reliable for short delays)
* - For delays >10 seconds: Uses AlarmManager (works even when app is backgrounded)
* - Uses AlarmManager (works even when app is backgrounded)
* - Android 13+: Also marks clipboard content as sensitive
*
*
* @param text - The text to copy to clipboard
* @param expirationSeconds - Number of seconds after which clipboard should be cleared (0 = no expiration)
*/
@@ -22,9 +21,9 @@ export async function copyToClipboardWithExpiration(
/**
* Copy text to clipboard without expiration.
*
*
* @param text - The text to copy to clipboard
*/
export async function copyToClipboard(text: string): Promise<void> {
await copyToClipboardWithExpiration(text, 0);
}
}