Search code examples
iosmobile-safari

Opening apps and closing Safari tabs on iOS


We have an App that accepts donations and per Apple's guidelines (item 21.2) we can't do this in-app, it must open a webpage in Safari to perform the donation. We've got that bit working fine, and we can actually automatically invoke the App post donation and put the user right back where they left off. The trouble is that the Tab in Safari persists when the user returns to Safari later.

Is there a way to open an app from a webpage while simultaneously closing said webpage in Safari?


Solution

  • So apparently the way to do it is via Javascript. You can set the window location and then immediately close the window.

    e.g.

    window.location = "myapp://?stuff";
    window.close;