【发布时间】:2015-11-11 22:53:34
【问题描述】:
我有一个为 ios 和 android 设备部署的流星应用程序,我希望某些代码仅在 ios 设备上运行,而不是在 android 上运行。我知道我可以使用 navigator.userAgent 检测设备,但这只有在我的应用程序在浏览器上运行时才有效。
//如果它是浏览器,则可以使用
navigator.userAgent.toLowerCase().indexOf("android") > -1;
但是,如果我使用流星科尔多瓦插件为 android 创建了捆绑包,是否有任何可能的方法来检测设备,这样它就可以像本机应用程序一样工作。
【问题讨论】:
-
您尝试过 Device API 吗?您可以检查 if(device.platform == 'Android')
标签: android cordova meteor device-detection