diff --git a/assets/Script/Manager.ts b/assets/Script/Manager.ts index c381719..6329ed2 100644 --- a/assets/Script/Manager.ts +++ b/assets/Script/Manager.ts @@ -62,14 +62,19 @@ export default class Manager extends cc.Component { self.Birdge(method, value); }; } - let scheme: string = "jmka"; + let scheme: string = "http"; this.webview.setJavascriptInterfaceScheme(scheme); this.webview.setOnJSCallback((sender: any, url: any) => { - let data: JSON = JSON.parse(decodeURI(url.split(`${scheme}://`)[1])); - let method: any = data["method"]; - let value: any = data["value"]; - if (method) { - self.Birdge(method, ...value); + let content: string = decodeURI(url.split(`${scheme}://`)[1]); + try { + let data: JSON = JSON.parse(content); + let method: any = data["method"]; + let value: any = data["value"]; + if (method) { + self.Birdge(method, ...value); + } + } catch (error) { + console.error(error); } }); }