Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
Window Open ignored on promise

I'm trying to redirect a user to twitter if they choose to. For that I use window.open but it just ignores that instruction. It works fine on other pages but in this function it's just not working. Any suggestions?

answerQuestion() {

        if (!this.isAnswerValid()) {
            this.presentToast('Answer must be between 1 and 140 characters')
            return
        }

        this.loading.present()
        this.questionsService.answerQuestion(this.question, this.answerText, this.imageURL)
        .then(res => {
            if (res) {
                if (this.twitter) {
                    let q = this.question.question
                    if (q.length > 100) {
                        q = q.substring(0, 101)
                    }
    
                    let a = this.answerText
                    if (a.length > 100) {
                        a = a.substring(0, 101)
                    }
                    const url = 'https://nonicapp.web.app/user/' + this.auth.user?.username
                    const tweet = q + " - " + a + " "
                    window.open('https://twitter.com/intent/tweet?text=' + tweet + '&hashtags=nonic&url=' + url, '_system')
                }
                this.router.navigateByUrl('/inbox', { replaceUrl: true });
            } else {
                this.presentToast('Something went wrong, please try again.')
            }
        })
        .catch(err => {
            console.warn(err)
            this.presentToast('Something went wrong, please try again.')
        })
        .finally(() => {
            this.loading.dismiss()
        })
    }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I also had some problems with window.open, so i started using Browser capacitor plugin

It's quite simple

import { Browser } from '@capacitor/browser';

... 

async openUrl(url) {
    await Browser.open({ url: url });
};
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!