This library is still under development and its use is not recommended yet.
Use
Installing
To install this library into your Angular project, just run the following command:
npm install ngx-platform-identifier --save
...and don't forget to import the library module into your Angular application module:
;
Getting platform information
The library provides two simple methods to check the platform, as the example shows:
;
Available checks
You may check information of the running browser, engine and OS. All the information checks and platform discovery works out-of-the-box:
// Checking if is running on an Android operating systemif this.platform.isOS.ANDROID // Checking compatibility with WebKit engineif this.platform.isCompatibleWithEngine.WEBKIT // Printing information about the running platformconsole.log'Running in the ', this.platform.engine.name, ' engine, version ', this.platform.engine.version; // Or just using the "toString()" helperconsole.log'Engine: ', this.platform.engine.toString;console.log'Browser: ', this.platform.browser.toString;console.log'OS: ', this.platform.os.toString;
False positives
Libraries like this one deeply depend on the user agent content to get the data. There's nothing to do when the user "hacks" this information in its browser - when using a plugin that changes it in order to emulate another platform, for instance.
Although, if you are sure that the library is returning an weird result and apparently there is no hack to mask the browser's user agent information, please feel free to file an issue in this repository with all the available information of your scenario, so we can check if it is a bug (no one is perfect!).
Issues
If you want to contribute reporting issues that you have found when using the library, it will be appreciated.
License
This library and its code is licensed under the MIT License.