I want to get the model name of mobile device like iphone 7, iphone 8 or iphone 12 when my web app runs on mobile but I only get iphone and not the specific device model. I m currently using react-device-detect.
Is there any way to achieve this? I don't want to use any paid service.
Any help will be appreciated. Thanks.
code:
import {deviceDetect,mobileModel} from "react-device-detect"
....
useEffect(() => {
console.log("devicedata deviceDetect", deviceDetect()) // gives object shown in image below
console.log("devicedata browserName", mobileModel) // gives "iphone"
},[])
output:

You can read the user agent api data and do some regular expression to extract the useful information
const userAgent= navigator.userAgent
const device = {
iPad: /iPad/.test(userAgent),
iPhone: /iPhone/.test(userAgent),
Android5: /Android 5/.test(uauserAgent,
Android4: /Android 4/.test(uauserAgent
}
Read more about detecting information Detect Device - Broswer