I am using custom url scheme to transfer some data from WKWebView to App.
The JS code I use in WKWebView is similar to this:
try{
window.location.href = 'bsfit://'+window.some_custom_data;
}catch(err){
alert(err);
}
Before iOS 15.4, this has worked perfectly.
When tested on iOS 15.4 Beta5, I got an error "TypeError: Invalid URL".
Is this change intended in iOS 15.4 regarding custom URL schemes?
Since I can't change the existing app code, is there a workaround?
Thanks.
We solved the problem. Use encodeURIComponent
to process the data string.
It looks like this.
try{
window.location.href = 'bsfit://'+encodeURIComponent(window.some_custom_data);
}catch(err){
alert(err);
}
For now, this method is compatible with iOS 15.4 and earlier versions (iOS >= 9).