Venkat
Venkat

Reputation: 841

How to Check Mobile/Web in HTML 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?

Upvotes: 6

Views: 4149

Answers (3)

Soro Mamadou
Soro Mamadou

Reputation: 11

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

if (/Mobi/.test(navigator.userAgent)) {
    //on Mobile
}else{
    //not on mobile
}

Upvotes: 1

mhsallam
mhsallam

Reputation: 245

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

Upvotes: 5

Hubert OG
Hubert OG

Reputation: 19544

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.

Upvotes: 8

Related Questions