有没有办法检测我的应用程序当前是在Ripple Emulator上运行,而不是真正的设备?我想要一些解决方法代码只能在模拟器上运行。
答案 0 :(得分:1)
您需要检查userAgent
对象中的navigator
属性,并使用window.parent.ripple
检查DOM上的涟漪实例。 Ripple-Emulator是browser
userAgent。也许你要添加firefoxOS。 :)
//check if the application is running on a mobile device or desktop
if (navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|IEMobile)/)
&& !window.parent.ripple) {
app.deviceType = 'mobile';
} else {
app.deviceType = 'browser';
}