question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ZoneAwareError on with angular and iOS simulator

See original GitHub issue

I am using the plugin in a location.provider.ts whose saveUserLocation method (see code below) is called from my “home” page. Everything works find on Android and a real iOS device, however on the iOS simulator it most of the times gives me this error below and sometimes it just gives me the expected result (the location object).

{"line":994,"column":38,"sourceURL":"file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js","originalStack":"ZoneAwareError@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:994:38\nfile:///app/tns_modules/nativescript-geolocation/geolocation.js:160:41\ninvoke@file:///app/tns_modules/tns-core-modules/timer/timer.js:54:53\nonInvoke@file:///app/tns_modules/@angular/core/bundles/core.umd.js:4787:39\nrunGuarded@file:///app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:138:53\ntick@file:///app/tns_modules/tns-core-modules/timer/timer.js:19:26\nUIApplicationMain@[native code]\nstart@file:///app/tns_modules/tns-core-modules/application/application.js:258:26\nbootstrapApp@file:///app/tns_modules/nativescript-angular/platform-common.js:86:28\nbootstrapModule@file:///app/tns_modules/nativescript-angular/platform-common.js:72:26\nanonymous@file:///app/main.j

Any idea as to what may cause this? I don’t care too much if this happens only on the simulator, I am a little worried it might also happen on a real device even though I have not seen it yet.

Thanks!

Which platform(s) does your issue occur on?

  • iOS simulator v10

Please, provide the following version numbers that your issue occurs with:

$ tns info
✔ Getting NativeScript components versions information...
⚠ Update available for component nativescript. Your current version is 4.1.0 and the latest available version is 4.1.1.
⚠ Update available for component tns-core-modules. Your current version is 3.4.1 and the latest available version is 4.1.0.
⚠ Update available for component tns-android. Your current version is 3.4.2 and the latest available version is 4.1.3.
⚠ Update available for component tns-ios. Your current version is 3.4.1 and the latest available version is 4.1.1.
{
  "description": "MyApp",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "com.abhayastudios.testapp",
    "tns-ios": {
      "version": "3.4.1"
    },
    "tns-android": {
      "version": "3.4.2"
    }
  },
  "dependencies": {
    "@angular/animations": "~5.2.0",
    "@angular/common": "~5.2.0",
    "@angular/compiler": "~5.2.0",
    "@angular/core": "~5.2.0",
    "@angular/forms": "~5.2.0",
    "@angular/http": "~5.2.0",
    "@angular/platform-browser": "~5.2.0",
    "@angular/platform-browser-dynamic": "~5.2.0",
    "@angular/router": "~5.2.0",
    "@teammaestro/nativescript-svg": "^1.0.1",
    "moment": "^2.18.1",
    "nativescript-angular": "~5.2.0",
    "nativescript-bitmap-factory": "^1.7.1",
    "nativescript-feedback": "^1.1.2",
    "nativescript-geolocation": "^4.2.6",
    "nativescript-gradient": "^2.0.1",
    "nativescript-image-swipe": "^2.1.0",
    "nativescript-imagepicker": "^5.0.0",
    "nativescript-iqkeyboardmanager": "^1.2.0",
    "nativescript-ngx-slides": "^1.0.0",
    "nativescript-platform-css": "^1.6.5",
    "nativescript-plugin-firebase": "^5.3.1",
    "nativescript-social-share": "^1.5.0",
    "nativescript-theme-core": "~1.0.4",
    "nativescript-ui-listview": "^3.5.0",
    "nativescript-webview-interface": "^1.4.1",
    "reflect-metadata": "~0.1.8",
    "rxjs": "~5.5.2",
    "tns-core-modules": "~3.4.1",
    "zone.js": "^0.8.16"
  },
  "devDependencies": {
    "babel-traverse": "6.26.0",
    "babel-types": "6.26.0",
    "babylon": "6.18.0",
    "lazy": "1.0.11",
    "nativescript-dev-typescript": "~0.6.0",
    "typescript": "~2.6.2"
  }

Is there any code involved?

This the relevant part of my location.provider.ts:

/*
     First obtain permissions to use location services if needed, then try to obtain user's location
  */
  public saveUserLocation() {
    return new Promise((resolve, reject) => {

      geolocation.isEnabled().then((isEnabled:boolean) => {

        /* already have location permissions */

        if (isEnabled) {
          this.getCurrentLocation().then((location) => {
            resolve(location);
          }, (error) => {
            reject(error);
          });

        } else {

          /* first request location permissions */

          geolocation.enableLocationRequest().then(() => {

            /* granted location permissions, now get location */

            this.getCurrentLocation().then((location) => {
              resolve(location);
            }, (error) => {
              reject(error);
            });
          }, (error) => {
            console.error(`Failed to obtain location permissions: ${JSON.stringify(error)}`);
            reject(error);
          });
        }
      })
    });
  }

  /*
    Try to obtain user's location, assumes permissions are handled and save to user session if successful
    
    Returns promise containing location
  */
  private getCurrentLocation() {
    return new Promise((resolve, reject) => {
      geolocation.getCurrentLocation({
        desiredAccuracy: Accuracy.any,
        iosAllowsBackgroundLocationUpdates: false,
        maximumAge: 5000, // in milliseconds
        timeout: 5000, // in milliseconds
      })
      .then((location) => {
        resolve(location);
      }, (error) => {
        console.error(`Failed to obtain user location: ${JSON.stringify(error)}`);
        reject(error);
      });
    });
  }

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
abhayastudioscommented, Jun 27, 2018

Still happening after upgrading to latest Xcode (now 9.4.1). Anyway, as long as this happens only on the simulator, it is not that important to me.

0reactions
aosi87commented, Oct 7, 2020

This is still an issue, did you guys figure it out yet?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ionic 4/Angular 7 App On iOS Simulator Error - Stack Overflow
Seems like in your component you are using ViewEncapsulation.Native thats why angular is calling createShadowRoot() when running natively.
Read more >
Cordova's plugins (screen-orientation / app-version) not ...
Coding example for the question Cordova's plugins (screen-orientation / app-version) not working on Ionic 5 / Angular 11-angular.js.
Read more >
Preview NativeScript apps in the iOS Simulator | egghead.io
Create Native Mobile Apps with NativeScript for Angular · 1. Set up a native mobile app using the NativeScript CLI · 2. Preview...
Read more >
Push Notifications Ionic/Angular &… | Apple Developer Forums
The moment I ran the app on Xcode with an iphone simulator everything went well, the message came up asking if I want...
Read more >
Your first Phonegap App with Mobile Angular Ui
We assume you can run your Phonegap application somehow (Android SDK, IOS Simulator, deploy to device). Why not just Twitter Bootstrap and Angular...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found