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.
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';
}
"Mozilla/5.0 (Linux; U; Android 2.3.2; en-us; Nexus S Build/GRH78C) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
–
Somerville you can check if a ripple instance is aviable:
if(typeof window.parent.ripple ==="undefined")
if ripple is a object, ripple is running otherweise ripple is not running! Quick and easy.
try to explain:
The target app runs in an iframe. If a ripple session has started is an object named "ripple" instantiated (at this point it does not matter what makes the object "ripple"). It's enough just to know that the object has been created. Because with this knowledge, we know that the app runs in a ripple container.
With window.parent
we can query the parent node of a iframe, in this case, the ripple environment in which there is also the ripple object.
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';
}
"Mozilla/5.0 (Linux; U; Android 2.3.2; en-us; Nexus S Build/GRH78C) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"
–
Somerville © 2022 - 2024 — McMap. All rights reserved.
function isOnRippleEmulator() { if (navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|IEMobile)/)) { return false; } else { return true; } }
– Emmott