Search code examples
cordovaemulationhybridripple

How can I detect, that my app is running on the Ripple Emulator?


Is there a way to detect, that my application is currently running on the Ripple Emulator, instead of a real device? I want some workaround code to be ran only on the emulator.


Solution

  • You need to check the userAgent property in navigator object and check for a ripple instance on your DOM with window.parent.ripple. Ripple-Emulator is a browser userAgent. Maybe you going to add firefoxOS. :)

    Hint: This is not a direct case of ripple emulator. It allows to detect browser or mobile device in 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';
    }