Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Check Mobile/Web in HTML Meteor?

Tags:

meteor

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?

like image 233
Venkat Avatar asked Feb 13 '14 04:02

Venkat


3 Answers

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.

like image 58
Hubert OG Avatar answered Nov 15 '22 11:11

Hubert OG


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

like image 31
mhsallam Avatar answered Nov 15 '22 11:11

mhsallam


If someone is still looking for this, he can try this JS test:

if (/Mobi/.test(navigator.userAgent)) {
    //on Mobile
}else{
    //not on mobile
}
like image 37
Soro Mamadou Avatar answered Nov 15 '22 10:11

Soro Mamadou