Angular 如何在Android中从嵌入式WebView导航到应用程序

Angular 如何在Android中从嵌入式WebView导航到应用程序,angular,capacitor,Angular,Capacitor,我们正在将支付系统与我们的应用程序集成。它在iOS上运行得很好,但在Android上导航回应用程序却不起作用。我们想在我们的应用程序中打开支付系统网页。为此,我们在capactor.config.json中设置了此配置: { "server": { "allowNavigation": ["sis-t.redsys.es", "*.redsys.es"] } } 现在,集成系统有点棘手。我们需要一个触发帖子的表单组件: 在我们的app.component.ts中,我们有以下

我们正在将支付系统与我们的应用程序集成。它在iOS上运行得很好,但在Android上导航回应用程序却不起作用。我们想在我们的应用程序中打开支付系统网页。为此,我们在
capactor.config.json
中设置了此配置:

{
  "server": {
    "allowNavigation": ["sis-t.redsys.es", "*.redsys.es"]
  }
}
现在,集成系统有点棘手。我们需要一个触发帖子的表单组件:


在我们的
app.component.ts
中,我们有以下代码:

从'@angular/core'导入{Component}
从“@angular/Router”导入{Router}
从“@capactor/core”导入{电容器,插件}
@组成部分({
选择器:'应用程序根',
templateUrl:'app.component.html',
样式URL:['app.component.scss']
})
导出类AppComponent{
私有url=新url(window.location.href)
构造函数(专用只读路由器:路由器){}
异步ngOnInit(){
if(this.url.searchParams.has('r')){
if(电容器.isNative){
等待Plugins.App.openUrl({url:this.url.href})
等待此消息。getLaunchUrl()
}否则{
等待这个.router.navigateByUrl(this.url.href.split('.com').pop()!)
}
}
}
异步getLaunchUrl(){
const urlOpen=wait Plugins.App.getLaunchUrl()
if(urlOpen&&urlOpen.url){
等待这个.router.navigateByUrl(this.url.href.split('://localhost').pop())
}
}
}
当它打开支付系统应用程序时,所有这些都可以工作。现在,这个系统允许我们设置重定向页面,以便导航回我们的应用程序。我们已经设置了
capacitor://localhost/store?r=ko
。正如文档中所述,iOS的方案是
电容器://
,而Android的方案是
http://
。因此,当我们完成操作并尝试通过点击iOS上的按钮返回应用程序时,它会完美地返回到应用程序,但Android不会

我们尝试在iOS中将url设置为
capacitor://localhost/store?r=ko
和Android中的to
http://localhost/store?r=ko
,但在Android中,它会尝试打开浏览器,这是我们不想要的

我们已尝试将
androidScheme
设置为
电容器
,但它会中断http请求。我们还尝试将
AndroidManifest.xml
属性
android:launchMode
更改为
singleTop
,如中所述。我们尝试将
strings.xml
更改为以下内容:

<?xml version='1.0' encoding='utf-8'?>
<resources>
    <string name="app_name">app</string>
    <string name="title_activity_main">app</string>
    <string name="package_name">com.app</string>
    <string name="custom_url_scheme">com.app</string>
</resources>

应用程序
应用程序
com.app
com.app
并将回调url设置为
com。app://localhost/store?r=ko
但什么也没有


我们尝试了一些带有深度链接的配置,但由于我们在应用程序内部,它不会导航到应用程序,因为我们不是来自外部站点。

尝试使用
/store?r=ko
重定向到应用程序页面(显然
存储
必须是路由器模块的已知路径)不@MedaiP90它不起作用,因为它必须是一个绝对的url,因为我们在de Webview内的网页中,没有角度或应用程序本身的概念。