fix(audio-message): iOS regression
This commit is contained in:
parent
8678263935
commit
5951f36291
1 changed files with 12 additions and 2 deletions
|
|
@ -339,8 +339,18 @@ export default function useVoiceRecorder() {
|
||||||
// Cancel any pending start when the app transitions away from active.
|
// Cancel any pending start when the app transitions away from active.
|
||||||
// This prevents a stalled promise from completing later and starting recording unexpectedly.
|
// This prevents a stalled promise from completing later and starting recording unexpectedly.
|
||||||
const sub = AppState.addEventListener("change", (state) => {
|
const sub = AppState.addEventListener("change", (state) => {
|
||||||
if (state !== "active") {
|
if (Platform.OS === "android") {
|
||||||
startAttemptRef.current += 1;
|
// 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 () => {
|
return () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue