【发布时间】:2022-01-11 09:04:46
【问题描述】:
到目前为止,在我的应用程序中,所有 window.open 调用在 iOS 上都可以正常工作,但这个调用使用的是异步函数。
有解决办法吗? 我花了几个小时从 stackoverflow 尝试各种事情。
我已经看到安装 inAppBrowser 可能会有所帮助,但我还没有尝试过。 https://capacitorjs.com/docs/apis/browser
我还看到将 window.open 放在 click 事件中可能会允许它,但这需要用户再次单击,这并不理想。
它在 Android 上运行良好。
<ion-button type="button" color="primary" expand="block" (click)="onCreateStripePortalSession()">
Manage my cards
</ion-button>
async onCreateStripePortalSession() {
const returnUrl = `https://myapp.app/goto/${this.tenant.slug}/account`;
try {
const session = await this.stripeService.createStripePortalSession(this.member.stripeCustomerId, returnUrl);
if (session.url) {
// Go to Stripe Customer Portal
window.open(session.url, '_blank');
}
} catch (err) {
console.log(err);
}
}
编辑: 此解决方案不起作用
let wref = window.open();
this.stripeService.createStripePortalSession(...).then(ps => {
wref.location = ps.url;
});
【问题讨论】:
标签: html ios ionic-framework capacitor