I'd like to use a bridge from iOS swift to Vuejs/ts without window.handler. Please share your ideas and experience

Hi everyone.

I am a new to iOS, and currently have a web view project with vue.js and typescript.

I am facing the issue that I cannot call a typescript function in vue.js side from iOS if I do not use window.[handler] = { } in onMounted.

I registered window.[handler] in main.ts to remove it from each vues, however, it didn't work.

if I declare this code in each vue.js, then I don't have an issue in a local server(vuejs), but Jenkins gets this as an issue.

If you have any opinions, experience or ideas, please share with me here.

Thanks in advance.

Here is my vue/ts for your information:

<script lang="ts" setup>

onMounted(async () => { // it works window.iOS = {

receiveMessage: (message) => { var volumeFloat = parseFloat(message); volume.value = Math.round(volumeFloat * 100); return &#039;result&#039;; }, }

});

In Xcode, I have an error message as below:

WKJavaScriptExceptionMessage=ReferenceError: Can't find variable: receiveMessage NSLocalizedDescription=JavaScript exception

I'd like to use a bridge from iOS swift to Vuejs/ts without window.handler. Please share your ideas and experience
 
 
Q