-1

Is there any good way to 100% detect if user device is IPhone 5(and not SE). To be correctly i need to know if IOS device model is < than IPhone 6 and != IPhone SE.

Checking CPU speed as i think is not a correct way for device detection.

onemantoo
  • 21
  • 3
  • "I need to know…", why? Are iPhone 4, 3 and many similar devices OK? – RobG Sep 26 '18 at 09:45
  • 4
    Possible duplicate of [How to determine which iPhone version the javascript code runs on?](https://stackoverflow.com/questions/8309998/how-to-determine-which-iphone-version-the-javascript-code-runs-on) – Jack Bashford Sep 26 '18 at 09:48
  • @RobG Apple pay works on all iphones > 5 and SE. And there is some issues which force me to detect iphone model and not only Apple Pay support. – onemantoo Sep 26 '18 at 10:27
  • You just need to test if `window.ApplePaySession` exists, that's it. See [*Checking for Apple Pay Availability*](https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/checking_for_apple_pay_availability) Even if detecting the device was reliable, you still can't be sure that Apple Pay is supported. – RobG Sep 26 '18 at 13:21

2 Answers2

0

If you're trying to detect support for Apple Pay, then according to the Apple developer support web site:

Before displaying an Apple Pay button or creating an Apple Pay session, you must ensure that the Apple Pay JS API is available and enabled on the current device. To check whether the Apple Pay JS API is available in the browser, verify that the window.ApplePaySession class exists:

if (window.ApplePaySession) {
   // The Apple Pay JS API is available.
}
RobG
  • 142,382
  • 31
  • 172
  • 209
  • I know how to detect ApplePaySupport, also i know some issues with ApplePaySession, iPhone 5 and mark "ApplePay Enabled". The main question is about detecting phone model, i don't need your help with ApplePay, thx. – onemantoo Sep 26 '18 at 14:24
  • @onemantoo—is your strategy is to check for compatible models of iPhone, iPad, Apple Watch, MacBook, etc.? In Japan you'll need iPhone 8, China presents other issues. – RobG Sep 26 '18 at 20:36
-2

You can ask for model name, iPhone SE is iPhone8,4 and iPhone 5S are iPhone6,1 & iPhone6,2.

Blind Ninja
  • 1,063
  • 13
  • 28