Notalib / nativescript-webview-ext

Nativescript plugin with extended WebView functionality
Apache License 2.0
76 stars 37 forks source link

X-Local Fetching Failed on Testflight version #139

Open louisportalest opened 1 year ago

louisportalest commented 1 year ago

Which platform(s) does your issue occur on? iOS - 15.6

Please, provide the following version numbers that your issue occurs with: CLI: 8.3.2 iOS: XCode version 13.4.1 nodejs: v14.18.0 Runtime(s): 8.3.2 Plugin(s): ^8.0.2

First of all, thank you for this plugin. I have a line of code that fetches a png file from local to the webview. It works perfectly fine on simulator or debug on real iphone device but when i test it on Testflight build, it return TypeError: Load failed.

Loading local resource :

this.e_sphereWebView.registerLocalResource('info', '~/app/assets/images/shared/info.png'),

Fetching from webview.js :

const fetchInfoSign1 = fetch('x-local://info') .then(response => response.blob()) .then(imageBlob => URL.createObjectURL(imageBlob)) .catch((error) => { console.dir(error) window.nsWebViewBridge.emit("log", error); window.alert("GetInfoSign " + error); });

I suspect it might related to cors issues but im not sure cause everything is working fine on simulator. Is there any special set up that i need to do for this? Please advice.

m-abs commented 1 year ago

I doubt it is cors problems, we should already handle those unless something changed in iOS 15.6?

Is TypeError: Load failed from the webview or from NativeScript?

louisportalest commented 1 year ago

I doubt it is cors problems, we should already handle those unless something changed in iOS 15.6?

Is TypeError: Load failed from the webview or from NativeScript?

The error is from webview. Only testflight build will have this error when loading the webview.

const fetchInfoSign1 = fetch('x-local://info')
        .then(response => response.blob())
        .then(imageBlob => URL.createObjectURL(imageBlob))
        .catch((error) => {
            // TypeError: Load failed
        });
m-abs commented 1 year ago

It sounds like you were right about the cors problem, but I'm unsure how to help.

You might be able to get more information from XCode and look at the native log. Look for "CustomUrlSchemeHandler" You should be able to make a "release" build locally and run it on your device or simulator.

https://docs.nativescript.org/releasing.html#ios