Home > Net >  Is there a way to detect iPhone model using js?
Is there a way to detect iPhone model using js?

Time:12-14

I need to detect the user's iPhone model and if it's lower than iPhone X (e.g. iPhone 8) - not to run some powerful logic (camera access and face masks via webGl), because weak devices can't run it without crashing ((

So is there any way to identify the iPhone model using js?

I was searching for solution, find some API, but they cost money )

And saw how someone was using device height and width, but not sure if it works correctly

CodePudding user response:

There is no baked in way to do that. There are way to do it but none are perfect and all have drawbacks

User-agents don't give that information, but you can compare it's string to known devices user-agent strings

Since you use react, this is what React-device-detect does.

another way like you said is to use the resolution and compare it to known devices resolution. You could take a look at that unmaintained library to get some ideas (you will need to expend their list since it's 4 years old)

The best solution is probably a mix of those methods in order to target as accurately as possible the models you want.

CodePudding user response:

You can use

navigator.userAgent 
  • Related