Device Type - iPhone or Android

Is it possible to create JavaScript code that will determine your device type? i.e. Android or iPhone?

Thanks,

Alberto

Hello @adasilva,

You can use navigator userAgent property to determine the user's device. For instance:

if( /Android/i.test(navigator.userAgent) ) {
 alert('android');
}
if( /iPhone/i.test(navigator.userAgent) ) {
 alert('iPhone');
}

Find more information here.

Also, you can use the approach from this post.

1 Like