My website uses Javascript to detect when someone is accessing it from a mobile device. This detection method was effective until Apple updated their iPad OS from IOS 13.1 to iPadOS 13.1.
The code I use for detection is as follows:
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) )
{
// alert('This is a mobile device');
}
This code worked fine on devices running IOS 13.1, with the navigator.userAgent showing this:
Mozilla/5.0 (iPad; CPU OS 12_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Mobile/15E148 Safari/604.1
However, after the update to iPadOS 13.1, the user agent now appears as:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.1 Safari/605.1.15
This new user agent string is similar to that of an Apple Mac, making it difficult to distinguish between mobile and desktop devices based on user agent alone.
While checking screen size could be a solution, the wide variety of mobile devices makes this method less reliable. Does anyone have any suggestions on how to address this issue?