Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect iPhone X (Ionic - cordova app)

I need to make some changes to my app but only for iPhone X.

The app is Apache Cordova based (with Ionic framework).

Is there a cordova plugin to detect the iPhone X? If the answer is no, which is the best method to know if the user has an iPhone X in javascript?

Thanks

like image 718
Ernesto Schiavo Avatar asked Oct 12 '17 08:10

Ernesto Schiavo


People also ask

How do I test an Ionic app on real device?

To run your app, all you have to do is enable USB debugging and Developer Mode on your Android device, then run ionic cordova run android --device from the command line. Enabling USB debugging and Developer Mode can vary between devices, but is easy to look up with a Google search.

Does Ionic work on iOS?

Because of this foundation in web technologies, Ionic can run anywhere the web runs — iOS, Android, browsers, PWAs, and more.

What is Iphone Ionic app?

Ionic provides a set of tools for building native iOS and Android applications, and mobile-ready Progressive Web Apps, using familiar web libraries, frameworks, and languages. Ionic Capacitor is a cross-platform native bridge that allows you to turn any web project into a native iOS or Android mobile application.


1 Answers

Check: var deviceInformation = ionic.Platform.device();

From Ionic bundle.js

/**
     * @ngdoc method
     * @name ionic.Platform#device
     * @description Return the current device (given by cordova).
     * @returns {object} The device object.
     */
    device: function() {
      return window.device || {};
    },

Also check cordova-plugin-device

Properties

device.cordova       // returns CDV_VERSION
 device.model
 device.platform     // always returns iOS
 device.uuid
 device.version
 device.manufacturer // always returns  Apple
 device.isVirtual    // not relevant
 device.serial 

This plugin calls CDVDevice.m -> UIDevice so if you still cannot fetch iPhone X worth to find the way how to detect it in Obj-C and change CDVDevice.m.


Also check this QA: iOS devices return different format device model, why?

like image 124
Maxim Shoustin Avatar answered Oct 30 '22 00:10

Maxim Shoustin