We are looking to develop a salesforce lightning app that is compatible with both mobile and desktop devices. In order to customize the code for the mobile app specifically, we need to find a way to detect whether the app is running on a mobile browser or a desktop browser. I have tried using the following code, but it seems to be ineffective:
checkMobileBrowser: function(component){
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){
return true;
}else{
return false;
}
}