Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Cannot read property 'osVersion' of undefined at iOS #270

Description

@zabi90

Hi,
I just created new NativeScript with Angular shared code project and added nativescript-geolocation dependencies. It is working fine so far inside android but giving error Cannot read property 'osVersion' of undefined at iOS when i used this method geolocation.enableLocationRequest(true, true)
Package.json

{
    "name": "HelloNativeScriptAngular",
    "main": "main.tns.js",
    "version": "0.0.0",
    "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e",
        "android": "tns run android --no-hmr",
        "ios": "tns run ios --no-hmr",
        "mobile": "tns run",
        "preview": "tns preview",
        "ngcc": "ngcc --properties es2015 module main --first-only",
        "postinstall": "npm run ngcc"
    },
    "private": true,
    "dependencies": {
        "@angular/animations": "~10.1.0",
        "@angular/common": "~10.1.0",
        "@angular/compiler": "~10.1.0",
        "@angular/core": "~10.1.0",
        "@angular/forms": "~10.1.0",
        "@angular/platform-browser": "~10.1.0",
        "@angular/platform-browser-dynamic": "~10.1.0",
        "@angular/router": "~10.1.0",
        "@nativescript/angular": "~10.1.0",
        "@nativescript/core": "~7.0.0",
        "@nativescript/theme": "~2.5.0",
        "core-js": "^3.6.0",
        "nativescript-geolocation": "^5.1.0",
        "reflect-metadata": "~0.1.12",
        "rxjs": "~6.6.0",
        "tslib": "1.10.0",
        "zone.js": "~0.11.1"
    },
    "devDependencies": {
        "@angular-devkit/build-angular": "~0.1001.0",
        "@angular/cli": "~10.1.0",
        "@angular/compiler-cli": "~10.1.0",
        "@nativescript/android": "7.0.0",
        "@nativescript/ios": "7.0.1",
        "@nativescript/tslint-rules": "~0.0.5",
        "@nativescript/webpack": "~3.0.0",
        "@types/jasmine": "~3.5.0",
        "@types/jasminewd2": "~2.0.3",
        "@types/node": "^12.11.1",
        "codelyzer": "^5.1.2",
        "jasmine-core": "~3.5.0",
        "jasmine-spec-reporter": "~4.2.1",
        "karma": "~4.4.1",
        "karma-chrome-launcher": "~3.1.0",
        "karma-coverage-istanbul-reporter": "~2.1.0",
        "karma-jasmine": "~3.0.1",
        "karma-jasmine-html-reporter": "^1.4.2",
        "protractor": "~5.4.3",
        "ts-node": "~8.3.0",
        "tslint": "~6.1.0",
        "typescript": "~3.9.0"
    }
}

and my component code is

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

import * as geolocation from "nativescript-geolocation";
 import { Accuracy } from "@nativescript/core/ui/enums";


@Component({
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.css'],
})
export class HomeComponent implements OnInit {
  title = 'HelloNativeScriptAngular';

  constructor() { }

  ngOnInit() {
  }

  public enableLocationTap(){
      geolocation.isEnabled().then(function (isEnabled) {
        if (!isEnabled) {
            geolocation.enableLocationRequest(true, true).then(() => {
                console.log("User Enabled Location Service");
            }, (e) => {
                console.log("Error: " + (e.message || e));
            }).catch(ex => {
                console.log("Unable to Enable Location", ex);
            });
        }
    }, function (e) {
        console.log("Error: " + (e.message || e));
    });
  }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions