Running audio recording features within Telegram Mini Apps can be tricky because the web view environment of the in-app browser has certain limitations, including restrictions on some APIs and potential variations in behavior across devices. Here are a few troubleshooting and workaround suggestions:
Check for User Permission Issues Some in-app browsers can handle permissions differently. It might be that the Telegram web view does not fully support the getUserMedia permissions request, causing issues with MediaRecorder. Try explicitly handling the permission request like so:
try { const stream = await navigator.mediaDevices.getUserMedia({ audio: true }); } catch (error) { console.error("Microphone permission denied:", error); }
Review App Constraints App may have restrictions on background processes or continuous audio access, especially on iOS where permissions are more restrictive in in-app browsers.
Implement Fallback Handling In some cases, audio handling in the web view may be unsupported. You could try detecting if the web view supports the required
if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) { alert("Audio recording is not supported in this environment."); }
Use audio/mp4 Instead of audio/wav Telegram web view might be better optimized for MP4 audio rather than WAV. To change the Blob type: