How can I detect that my application is running in a Ripple emulator?

Is there a way to detect that my application is currently running on a Ripple emulator instead of a real device? I want the bypass code to run only on the emulator.

+7
cordova emulation ripple hybrid
source share
2 answers

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

Hint: this is not a direct case of ripple emulation. This allows you to discover a 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'; } 
+1
source share

you can check if ripple instance is available: if(typeof window.parent.ripple ==="undefined")

if ripple is an object, ripple works, another ripple does not work! Fast and easy.

try to explain:

The target application runs in the iframe. If a ripple session is started, an object with the name "ripples" is created (at the moment it does not matter what the object "ripples" does). This is enough to know that the object was created. Because, knowing this, we know that the application works in a ripple container.

With window.parent we can request the parent node iframe, in this case, a ripple environment in which there is also a ripple object.

+8
source share

All Articles