After some testing, I found out that the most upvoted answer isn't good for reusability and is ugly, so I ended up going with one of the other suggested solutions and created this method in my utils:
openInNewTab(url: string): void {
if (this.isSafari()) {
const a = document.createElement('a')
a.setAttribute('href', url)
a.setAttribute('target', '_blank')
setTimeout(() => a.click())
} else {
this.window.open(url, '_blank')
}
}
For those curious how I determine Safari:
// https://stackoverflow.com/a/70585394/20051807
isSafari(): boolean {
return (this.window as any).GestureEvent || this.window.navigator.userAgent.match(/iP(ad|od|hone)/i)
}
Tested on iPhone and Mac.