angular - 如何从 Ionic Capacitor 打开的 javascript 关闭窗口
问题描述
我在我的离子应用程序中打开窗口
await Browser.open({url: environment.apiUrl + `/myurl`});
但是当用户完成某些操作时,我想关闭它自己的窗口。我试过window.close
了,但由于安全问题,它不起作用。
我如何关闭那个窗口?
解决方案
Finally found the way.
- Register custom scheme
- In external app redirect
window.location.href="customschema://"
- For iOS listen for appUrlOpen and close browser, for android as soon as you redirect to custom schema will close.
Place into app.component on app start
if (this.platform.is('ios')) {
App.addListener('appUrlOpen', data => {
if (data.url.indexOf('comflymarkonline://')> -1) {
Browser.close();
}
});
}
推荐阅读
- pdfbox - Apache PDFBox - 添加多种字体
- angular - Observable 拆解中的 Promise/Deferred 代码
- r - 为什么excel中的数据不能插入r-markdown?
- excel - 使用 Excel 宏在多个工作簿中查找重复项
- macos - 如何使用触控板使用 iterm2 在 nano 中滚动,它在 terminal.app 中的工作方式?
- .net - Netsuite Web 服务 .net SDK。如何检索自定义字段的值/
- c++ - Hermite 曲线中的切线值
- java - 如何使用 ActiveJDBC 处理重新连接到数据库
- json - 使用 SCALA 解析嵌套的 JSON
- html - How to keep the size of a form in Bootstrap v3.7