| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 1 | /* |
| 2 | Copyright 2020 TATA ELXSI |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the 'License'); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | |
| 16 | Author: KUMARAN M (kumaran.m@tataelxsi.co.in), RAJESH S (rajesh.s@tataelxsi.co.in), BARATH KUMAR R (barath.r@tataelxsi.co.in) |
| 17 | */ |
| 18 | import { Injectable } from '@angular/core'; |
| 19 | import { BehaviorSubject, Observable } from 'rxjs'; |
| 20 | /** |
| 21 | * @file Provider for Device Check Service |
| 22 | */ |
| 23 | /** |
| 24 | * An Injectable is a class adorned with the @Injectable decorator function. |
| 25 | * @Injectable takes a metadata object that tells Angular how to compile and run module code |
| 26 | */ |
| 27 | @Injectable({ |
| 28 | providedIn: 'root' |
| 29 | }) |
| 30 | /** Exporting a class @exports DeviceCheckService */ |
| 31 | export class DeviceCheckService { |
| 32 | /** Get method for Observable isMobile */ |
| 33 | get isMobile(): Observable<boolean> { |
| 34 | return this.isMobile$.asObservable(); |
| 35 | } |
| 36 | /** Holds the mobile condition of type BehaviorSubject<boolean> @private */ |
| 37 | private isMobile$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false); |
| 38 | |
| 39 | /** Return the Device type @public */ |
| 40 | public checkDeviceType(): void { |
| SANDHYA.JS | 0a34dfa | 2023-04-25 23:59:41 +0530 | [diff] [blame] | 41 | if ((/Android/i.exec(navigator.userAgent)) |
| 42 | || (/webOS/i.exec(navigator.userAgent)) |
| 43 | || (/iPhone/i.exec(navigator.userAgent)) |
| 44 | || (/iPod/i.exec(navigator.userAgent)) |
| 45 | || (/BlackBerry/i.exec(navigator.userAgent)) |
| 46 | || (/Windows Phone/i.exec(navigator.userAgent))) { |
| kumaran.m | 3b4814a | 2020-05-01 19:48:54 +0530 | [diff] [blame] | 47 | this.isMobile$.next(true); |
| 48 | } else { |
| 49 | this.isMobile$.next(false); |
| 50 | } |
| 51 | } |
| 52 | } |