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
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.
Because of this foundation in web technologies, Ionic can run anywhere the web runs — iOS, Android, browsers, PWAs, and more.
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.
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With