How can I know which device was connected to my angular application? I would like to identify it to be able to make only devices ios can connect.
How can I know which device was connected to my angular application? I would like to identify it to be able to make only devices ios can connect.
Since you are doing your application in Angular5 I recommend this plugin: link
Demo: link
The other option is to use simple javascript.
Using navigator.userAgent
you can get the device, browser and other information:
$(document).ready(function(){
var ua = navigator.userAgent;
console.log(ua);
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(ua))
{
console.log('iOs');
}
else if(/Chrome/i.test(ua))
{
console.log('Chrome');
}
else
{
console.log('Desktop');
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>