如何检测我的应用程序是否在Ripple Emulator上运行?

时间:2014-07-19 11:55:27

标签: cordova emulation hybrid ripple

有没有办法检测我的应用程序当前是在Ripple Emulator上运行,而不是真正的设备?我想要一些解决方法代码只能在模拟器上运行。

1 个答案:

答案 0 :(得分:1)

您需要检查userAgent对象中的navigator属性,并使用window.parent.ripple检查DOM上的涟漪实例。 Ripple-Emulator是browser userAgent。也许你要添加firefoxOS。 :)

提示:这不是纹波仿真器的直接情况。它允许用JavaScript检测浏览器或移动设备。

//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';
}