Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating Dialog.alert inside .then((result) not working #264

Open
Rdevc opened this issue Apr 28, 2021 · 5 comments
Open

Creating Dialog.alert inside .then((result) not working #264

Rdevc opened this issue Apr 28, 2021 · 5 comments

Comments

@Rdevc
Copy link

Rdevc commented Apr 28, 2021

Hi!

When I use the scanner and the code scanned did not match a param an alert is triggered to let the user know the scan is wrong. So in the result I have the following line to test:

.then((result) => {
      const alertOptions = {
        title: 'Warning',
        message: 'Something terrible has happened.',
        okButtonText: 'Okay',
        cancelable: false // [Android only] Gets or sets if the dialog can be canceled by taping outside of the dialog.
      }

      Dialogs.alert(alertOptions).then(() => {
        console.log('Ok chosen!')
      })
    });

This bit of code results in the next warning/error:

Warning: Attempt to present <UIAlertController: 0x10309c000> on <QRCodeReaderViewController: 0x102468590> whose view is not in the window hierarchy!

No alert is showing up which is obvious if you look at the warning/error.

I'm using:
"@angular/core": "~11.2.5",
"@nativescript/core": "8.0.2",
"nativescript-barcodescanner": "^4.1.0",

Anyone a suggestion how to fix this? Is it a scanner issue or do I do something wrong?

Thanks in advance for any answer!!

@EddyVerbruggen
Copy link
Owner

I'm guessing wrapping that alert in a setTimeout should help.

@Rdevc
Copy link
Author

Rdevc commented Apr 28, 2021

Thanks for your answer!

I've tried that solution with a set timeout of 1000. The alert will work but when I hit te scan button again the alert appears again inside the scanner. After scanner two or three times ill get 3 alerts popping over each other.. It's like something is not closing and I'm still not sure if it is my code or something else.

As you can see I'm not using complex code or something.

@EddyVerbruggen
Copy link
Owner

Hmm, maybe you're showing the scanner inside a modal? Not that that's wrong, but it may be an edge case, combined with an alert. I don't really have time to look into it.. but maybe using a Toast or something else than an alert will get around it?

@Rdevc
Copy link
Author

Rdevc commented Apr 28, 2021

Got it, thank you!

presentInRootViewController: true

This was the issue.. I've copied the code from GitHub and your last message got me thinking about the modal..

it looks like

Fullscreen: true or Fullscreen: false

is not doing anything but deleting excluding the "presentInroot" showed me an alert without any warning or error.

Maybe I'll look into that in te future if I got some time and know how to debug the plugin but for now its ok for me.

It's up to you if you want this issue to be open to work on it later or close it.

Kind regards.

@EddyVerbruggen
Copy link
Owner

Oh that's nice! Glad you found a way to make it disappear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants