Alert function not working (iOS)



I can’t seem to get the alert function to work. I’ve tried:

// 1.

// 2.
import * as dialogs from 'ui/dialogs';

// 3.
import * as dialogs from 'tns-core-modules/ui/dialogs'; // Shouldn't be needed at all.

I’ve read:

But I can’t get it working following that. Any idea what is happening? Why it’s not working at all?

I’m on iOS. And using Nativescript + Angular.


It should work.

Are you getting any errors?
Are you able to reproduce the issue with Playground?


I’m not getting any errors. But the code is definitely executed since I have a console.log there too. I’ve tried a full rebuild too, deleted the ios folder after every combination of importing and not importing ../ui/dialogs.

Didn’t try it in the playground.

The only slightly “bigger” change I’ve made to the angular template I started from was replace page-router-outlet with router-outlet to allow child routes in named router-outlets. But That shouldn’t have an impact on that I would assume.


This is my bootstrapped file now, as simple as I can think of and it’s still not working:

import { Component, OnInit } from "@angular/core";

  selector: "my-app",
  template: `
      <Label text="Hi"></Label>
export class AppComponent implements OnInit {  
  ngOnInit() {
    alert('I will not show up!');

Also tried to put the alert in a setTimeout but nope.


Smells like this issue:

You could try with the @next version of tns-core-modules.


How about, I happened the same, I solved it by deleting the folders node_modules, hooks, platforms, then with a tns install verifies if all the folders that you deleted were generated and there is a tns run android or ios


I ended up using fancy-alert. Didn’t work for me with deleting node_modules and platform folder. Maybe if I tried deleting hooks also but now I’m just using this instead.


As Eddy mentioned you need at least one frame for alert to work, but it should be fixed in next release.