How do I prevent the Callback URL in iOS from opening in a new tab?

We’re using Square to process credit cards in our POS system and it works great on Android, but on iOS it always opens the callback URL in a new tab instead of the existing one. This is causing a lot of confusion since, for one, it opens a bunch of unnecessary tabs, and also, when the new tab is closed it looks like the transaction hasn’t been processed yet.

I’ve tried the following, but all have the same results:
window.location = “square-commerce-v1://payment/create?data=”+encodeURIComponent(JSON.stringify(parms));
window.location.href = “square-commerce-v1://payment/create?data=”+encodeURIComponent(JSON.stringify(parms));
window.open(“square-commerce-v1://payment/create?data=”+encodeURIComponent(JSON.stringify(parms)),’_self’);
location.assign(“square-commerce-v1://payment/create?data=”+encodeURIComponent(JSON.stringify(parms)));
location.replace(“square-commerce-v1://payment/create?data=”+encodeURIComponent(JSON.stringify(parms)));

I’ve also tried running our app in Chrome on iOS, but that’s even worse because the callback opens in a new SAFARI window rather than the chrome window where the link originated from.

How do I get the link to stay in the same tab like it should?

:wave: Unfortunately, we don’t really have control of that. Is Chrome set as the default browser on the iOS device? :slightly_smiling_face:

I can try that, but I’m more concerned about the link opening in a new tab in the first place. That shouldn’t be happening.

The SDK/iOS app runtime has no knowledge on what you have set as the default browser and no way of directly interacting with the browser. It basically just sends a request to the OS being like “please open this URL for me” and then the OS takes over, so there’s not really much we can do about controlling this behavior. This is because each app is sandboxed and cannot talk directly to other apps.

We suspect it’s in regards to the UX of reusing an existing tab, that that is not allowed to prevent applications from accidentally closing/navigating away from an existing tab that the seller had opened and might have wanted to keep around. :slightly_smiling_face:

Maybe I left out some details before, the Chrome part was an extra annoyance, not the root problem.

If I open the page in Safari and process a transaction, a new tab opens with the callback details. It shouldn’t be opening a new tab and I can’t find a way to prevent this. It only happens on iOS, not on Android nor on similar URL calls from desktop browsers.

Sadly with Safari that has been the behavior all along. There isn’t a way around it. :slightly_smiling_face: