See if it fixes your problem. If so, the reason it works is that the Promise coming from Stripe’s API isn’t zone-aware. I ran into this problem with Promises that come from WebCrypto, and wrapping them with another Promise.resolve is the cleanest way I came up with to zonify them. You could do something similar with NgZone.run, but I hate that because it needlessly exposes implementation details that should be subject to change.
Yeah I did try that.
The window.open works (although I need to give it a url) but it seems to lose the reference so the wref.location does not work. I think this probably only works for web.
OK, I think we’re at the point where this topic could be renamed “help me make Stripe play nicely with Safari’s popup blocker”.
There seem to be many different APIs and assorted plugins out there for interacting with Stripe. Perhaps an overview of which you are using under the hood here might help suggest further lines of inquiry.
Safari apparently really doesn’t want windows spawned from code that is not a direct response to a user input, which I guess is sort of understandable but probably sort of irritating in this precise situation. I’m sure you’re not the only one who’s hit this, but I think it’s important to focus on Stripe-related options, because generic attempts at solutions seem to be hitting a brick wall.
I’m going to search for a few more things to try.
The next thing I will try is the in app browser as I saw mention that it resolved the problem, even if you open the window in the system browser.
If none of that works I will resort to having two buttons or creating the portal session if the user goes to that page. Not great solutions but either should work.
I fixed it easily with the below but it is not a great solution as the user has click twice.
I may just leave it like this for a while rather than expending any more time on it.
const session = await this.stripeService.createStripePortalSession(this.member.stripeCustomerId, returnUrl);
if (session.url) {
// Go to Stripe Customer Portal
this.notificationService.presentAlertWithExternalUrlOption('Manage my Cards', 'Go to Stripe to manage your cards?', 'Lets go', session.url);
}
presentAlertWithExternalUrlOption(header: string, message: string, routeLabel: string, url: string) {
this.alertCtrl.create({
header,
cssClass: 'ion-alert-custom',
message,
buttons: [
{
text: 'Cancel',
role: 'cancel'
},
{
text: routeLabel,
handler: () => {
window.open(url, '_blank');
}
},
]
}).then(alertEl => {
alertEl.present();
});
}
Hello everyone.
Does someone have any news regarding this issue?
I use Capacitor, and my users log in using OpenID Connect (with angular-auth-oidc-client), because of company policies, we can’t use the inAppBrowser, and have to rely on the system browser.
So I managed to make it work using the solution provided by @wekas with a popup, but it’s definitely annoying for the users to clic on “Login”, and then have a popup to confirm that he, indeed, wants to login…
Thanks for your reply, but I feel like we’re going in circle here.
Opening safari works well on iOS 16.2 with window.open, as long as it’s not in an async function.
In the code I provided, opening safari works, it just does so on user action.
The plugins you provided uses inApp browser, and I can’t use that.
I really feel like it’s an issue with Ionic itself.