I have this code, that used to create transaction and then redirect user to page with this transaction:
const { detect } = require('detect-browser')
const browser = detect()
...
async beginTransaction (data) {
this.submitError = false
if (!this.validateData()) return
this.$store.commit('SET_LOADER', 1)
try {
this.captchaCounter++
const clientOrigin = localStorage.getItem('cOrigin')
const result = await startTransaction({
...data
}, this.offerId, localStorage.getItem('market'))
localStorage.removeItem('cOrigin')
const route = this.$router.resolve({path: '/chat', query: { id: result.transactionId, pushNotifications: null, beCareful: null }})
if (browser.name.toLowerCase() === 'safari' || this.$browserDetect.isSafari) {
await this.$router.push(`/chat?id=${result.transactionId}&pushNotifications&beCareful`)
} else {
return window.open(route.href, '_blank')
}
} catch (e) {
console.log(e)
}
}
This code works perfectly fine with every other browser or device, but not on iPhone with Safari. I tried probably everything that could found, I was trying to use window reference, like here. I was also trying to do it using .then(() => {}) like here and even this, but nothing works.
What is the problem? Could it be problem in phone, not code? Because I have similar code that works, but it is bonded on button click:
async redirectToChat (id) {
if (browser.name.toLowerCase() === 'safari' || this.$browserDetect.isSafari) {
await this.$router.push(`/chat?id=${id}`)
} else {
const route = this.$router.resolve({path: '/chat', query: { id }})
return window.open(route.href, '_blank')
}
},