How to check Mobile/Web in HTML Meteor for loading UI? .
if mobile //here how to check if it is mobile or web
{
{{>template}}// mobile body
}
else
{
{{>template}}//web body
}
I am new to Meteor. So please suggest me what to do?
You can do that easily with device-detection package.
First, install it via:
meteor add mystor:device-detection
Then you can use the provided helper methods like Meteor.Device.isPhone()
, or directly from Spacebars: {{#if isPhone}}Phone{{/if}}
. See the readme on Github for details.
If you simply want to check whether the app is running on a mobile environment you can use:
if(Meteor.isCordova)
Check out the other functions as well
If someone is still looking for this, he can try this JS test:
if (/Mobi/.test(navigator.userAgent)) {
//on Mobile
}else{
//not on mobile
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With