I use the Vue.js 3 language, together with Typescript, I created a pwa application and I want to create a voice button, but when I use this button created in my safari it works, when I add my application to the IOS home screen, it no longer works, I tested it with different versions of Ios.
an example of my code:
<template>
<div class="app-container">
<span
@touchstart="startRecording"
@touchend="stopRecording"
class="no-select microphone-button"
>
<el-icon :style="{ transform: isActive ? 'scale(2.3)' : 'scale(1.5)' }" id="microphone-button-margin">
<Microphone />
<span v-if="isActive" class="recording-indicator" />
</el-icon>
</span>
<p>Texto Reconhecido: {{ recognizedText }}</p>
</div>
</template>
<script setup lang="ts">
const recognizedText=ref('')
let recognition: any=null
const isActive=ref(false)
onMounted(() => {
recognition = new (window as any).webkitSpeechRecognition()
})
const startRecording = () => {
isActive.value = true
recognition.lang = 'pt-BR'
recognition.continuous = false
ElMessage.error('Start')
recognition.onresult = (event: { results: { transcript: any }[][] }) => {
ElMessage.success(event.results[0][0].transcript)
const transcript = event.results[0][0].transcript
recognizedText.value = transcript
}
recognition.start()
}
const stopRecording = () => {
isActive.value = false
ElMessage.error('Stop')
if (recognition) {
recognition.stop()
}
}
</script>
link code:
[https://element-plus.run/#eyJzcmMvQXBwLnZ1ZSI6IjxzY3JpcHQgc2V0dXAgbGFuZz1cInRzXCI+XG5pbXBvcnQgeyByZWYsIHZlcnNpb24gYXMgdnVlVmVyc2lvbiwgb25Nb3VudGVkIH0gZnJvbSAndnVlJ1xuaW1wb3J0IHsgdmVyc2lvbiBhcyBlcFZlcnNpb24sIEVsTWVzc2FnZSB9IGZyb20gJ2VsZW1lbnQtcGx1cydcbmltcG9ydCB7IE1pY3JvcGhvbmUgfSBmcm9tICdAZWxlbWVudC1wbHVzL2ljb25zLXZ1ZSdcblxuY29uc3QgcmVjb2duaXplZFRleHQ9cmVmKCcnKVxubGV0IHJlY29nbml0aW9uOiBhbnk9bnVsbFxuY29uc3QgaXNBY3RpdmU9cmVmKGZhbHNlKVxuXG5vbk1vdW50ZWQoKCkgPT4ge1xuICByZWNvZ25pdGlvbiA9IG5ldyAod2luZG93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xuICBoZWlnaHQ6IDMwcHg7XG4gIHdpZHRoOiA0MHB4O1xufVxuLnJlY29yZGluZy1pbmRpY2F0b3Ige1xuICBwb3NpdGlvbjogYWJzb2x1dGU7XG4gIHRvcDogLTVweDtcbiAgcmlnaHQ6IDEycHg7XG4gIHdpZHRoOiA3cHg7XG4gIGhlaWdodDogN3B4O1xuICBiYWNrZ3JvdW5kLWNvbG9yOiByZWQ7XG4gIGJvcmRlci1yYWRpdXM6IDUwJVxufVxuPC9zdHlsZT5cbiIsImltcG9ydC1tYXAuanNvbiI6IntcbiAgXCJpbXBvcnRzXCI6IHt9XG59IiwidHNjb25maWcuanNvbiI6IntcbiAgXCJjb21waWxlck9wdGlvbnNcIjoge1xuICAgIFwidGFyZ2V0XCI6IFwiRVNOZXh0XCIsXG4gICAgXCJqc3hcIjogXCJwcmVzZXJ2ZVwiLFxuICAgIFwibW9kdWxlXCI6IFwiRVNOZXh0XCIsXG4gICAgXCJtb2R1bGVSZXNvbHV0aW9uXCI6IFwiQnVuZGxlclwiLFxuICAgIFwidHlwZXNcIjogW1wiZWxlbWVudC1wbHVzL2dsb2JhbC5kLnRzXCJdLFxuICAgIFwiYWxsb3dJbXBvcnRpbmdUc0V4dGVuc2lvbnNcIjogdHJ1ZSxcbiAgICBcImFsbG93SnNcIjogdHJ1ZSxcbiAgICBcImNoZWNrSnNcIjogdHJ1ZVxuICB9LFxuICBcInZ1ZUNvbXBpbGVyT3B0aW9uc1wiOiB7XG4gICAgXCJ0YXJnZXRcIjogMy4zXG4gIH1cbn1cbiIsIl9vIjp7fX0=)
Can anyone help me in this case? I don't know what I could be doing wrong and I also did a lot of research and didn't see anything to help me.