From 5951f36291ce9bc7837084b309786e5ff0dfc9fe Mon Sep 17 00:00:00 2001 From: devthejo Date: Fri, 16 Jan 2026 18:09:52 +0100 Subject: [PATCH] fix(audio-message): iOS regression --- src/hooks/useVoiceRecorder.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/hooks/useVoiceRecorder.js b/src/hooks/useVoiceRecorder.js index 0e76809..4929808 100644 --- a/src/hooks/useVoiceRecorder.js +++ b/src/hooks/useVoiceRecorder.js @@ -339,8 +339,18 @@ export default function useVoiceRecorder() { // Cancel any pending start when the app transitions away from active. // This prevents a stalled promise from completing later and starting recording unexpectedly. const sub = AppState.addEventListener("change", (state) => { - if (state !== "active") { - startAttemptRef.current += 1; + if (Platform.OS === "android") { + // Android: cancel on any transition away from active (prevents delayed auto-start). + if (state !== "active") { + startAttemptRef.current += 1; + } + } else { + // iOS: permission prompts commonly put the app into `inactive` temporarily. + // Cancelling on `inactive` breaks first-run permission flow. + // Only cancel when truly backgrounded. + if (state === "background") { + startAttemptRef.current += 1; + } } }); return () => {