fix(audio-message): iOS regression
This commit is contained in:
parent
8678263935
commit
5951f36291
1 changed files with 12 additions and 2 deletions
|
|
@ -339,9 +339,19 @@ 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 (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 () => {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue