如何检测iPhone X(Ionic - cordova应用程序) [英] How to detect iPhone X (Ionic - cordova app)
问题描述
我需要对我的应用进行一些更改,但仅适用于iPhone X.
I need to make some changes to my app but only for iPhone X.
该应用是基于Apache Cordova的(使用Ionic框架)。
The app is Apache Cordova based (with Ionic framework).
是否有 cordova插件来检测iPhone X?如果答案是否定的,那么知道用户是否拥有iPhone X 在javascript 中的最佳方法是什么?
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?
谢谢
推荐答案
检查: var deviceInformation = ionic.Platform.device();
/**
* @ngdoc method
* @name ionic.Platform#device
* @description Return the current device (given by cordova).
* @returns {object} The device object.
*/
device: function() {
return window.device || {};
},
属性
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
此插件调用 CDVDevice.m - > UIDevice
所以如果你仍然无法获取 iPhone X
值得找到如何在Obj-C中检测它并更改 CDVDevice的方法。 m
。
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
.
同时检查此QA: iOS设备返回不同格式的设备型号,为什么?
这篇关于如何检测iPhone X(Ionic - cordova应用程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!