how to get device id of a computer and browser in angular 5?

Discussão em 'Angular' iniciado por Kumaresan Perumal, Setembro 16, 2024.

  1. [​IMG]I am working in WEB bank app with angular 5. the task is I want to find out device id of a computer and browser name.

    i tried this NPM module:

    npm install ngx-device-detector --save

    import { NgModule } from '@angular/core';
    import { DeviceDetectorModule } from 'ngx-device-detector';
    ...
    @NgModule({
    declarations: [
    ...
    LoginComponent,
    SignupComponent
    ...
    ],
    imports: [
    CommonModule,
    FormsModule,
    DeviceDetectorModule.forRoot()
    ],
    providers:[
    AuthService
    ]
    ...
    })

    import { Component } from '@angular/core';
    ...
    import { DeviceDetectorService } from 'ngx-device-detector';
    ...
    @Component({
    selector: 'home', // <home></home>
    styleUrls: [ './home.component.scss' ],
    templateUrl: './home.component.html',
    ...
    })

    export class HomeComponent {
    deviceInfo = null;
    ...
    constructor(..., private http: Http, private deviceService: DeviceDetectorService) {
    this.epicFunction();
    }
    ...
    epicFunction() {
    console.log('hello `Home` component');
    this.deviceInfo = this.deviceService.getDeviceInfo();
    console.log(this.deviceInfo);
    }
    ...
    }


    Output:

    {
    "userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36",
    "os":"windows",
    "browser":"chrome",
    "device":"unknown",
    "os_version":"windows-10",
    "browser_version":"66.0.3359.139"
    }


    I am getting browser name but not device id. take a look at JSON. the device is device: unknow.

    If any other options or NPM Modules, please recommend me to accomplish this task.

    please help me.

    Continue reading...

Compartilhe esta Página