#1 2017-01-31 18:14:17

eduardoalfaro
Member
Registered: 2016-06-08
Posts: 37

Is app running in tablet? With theUserAgent action or Cordova's plugin

Hello,

I am trying to add a new cordova/phonegap plugin to AppBuilder, this is the first time, and I really do not know if I am doing well.
Maybe one of you could help me with this issue.

I want to add the plugin "istablet" (https://github.com/dpa99c/phonegap-istablet) that detects if the APP is running on a tablet or not.
I followed the "add new plugins guide" (https://www.davidesperalta.com/Humm/Sit … ugins.html) for AppBuilder, so I added the ID on Cordova -> Apps Option -> Custom plugins: uk.co.workingedge.phonegap.plugin.istablet

Then I created the JS function istablet whith this code: alert("This device is "+(window.isTablet?'':'NOT')+" a tablet");

But all the time returns "This device is NOT a tablet", even if I run the app with a tablet emulator.

I also modified the function with this code: alert(window.isTablet);
But it returns "undefined" on the alertbox. ;-(

Could you help me with this???
Do you know any other easy way to detect if the apps is running on a tablet or not?

Thank you so much!!!
Eduardo

Offline

#2 2017-01-31 20:33:27

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: Is app running in tablet? With theUserAgent action or Cordova's plugin

Hello Eduardo,

First of all, maybe you don't know about the App Builder's UserAgent action. Please, take a look, and, in particular, at the "[ResultVar.device.type]" variable. If this is enough for you then probably you no need any Cordova's plugin here for this task.

Said that, certainly App Builder includes various Cordova's plugins "out-of-the-box", and, allow us to use any other like we can read in this help's tutorial. Also App Builder includes various samples that uses Cordova's plugins, so take a look at the samples: "CordovaPlugins", "SendSMS", ""Magneto" and "Launcher".

About your specific problem to implement the "IsTablet" plugin... testing here I think they works as expected. Please, Eduardo, (sorry, this is not well documented) be sure you check the "Dialogs" plugin in the app Cordova's options: at least in the past this plugin are required if we plain to use the "alert" function. On the other hand I think you do the correct job by implementing the plugin.

Anyway take a look at the sample that I prepare for the test: ITabletTest.zip. At least they works in my phone... which is NOT a tablet... but I can't try it in a tablet, sorry...

Offline

#3 2017-02-10 09:13:33

edunt
Member
Registered: 2015-12-21
Posts: 258

Re: Is app running in tablet? With theUserAgent action or Cordova's plugin

Hi Eduardo,

Did you get itablet working on your device?

AB rock!

Offline

#4 2017-02-10 09:50:36

eduardoalfaro
Member
Registered: 2016-06-08
Posts: 37

Re: Is app running in tablet? With theUserAgent action or Cordova's plugin

Hi edunt,
I am so sorry, but I could not try at moment, I will do this weekend and then I will tell all of you.
Thank you so much!!!
Eduardo

Offline

#5 2017-02-10 10:41:13

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: Is app running in tablet? With theUserAgent action or Cordova's plugin

Hello to all!

Anyone here are tried with the UserAgent action? smile

Offline

#6 2017-02-10 11:29:16

fakie
Banned
Registered: 2016-10-28
Posts: 36

Re: Is app running in tablet? With theUserAgent action or Cordova's plugin

Running it from windows, I do not get a device.type, device.vendor or device.model.
all the others a filled in.


This is my favourite quote.

Offline

#7 2017-02-10 11:29:51

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: Is app running in tablet? With theUserAgent action or Cordova's plugin

fakie wrote:

Running it from windows, I do not get a device.type, device.vendor or device.model.
all the others a filled in.

And running it in a table?

Offline

Board footer

Powered by FluxBB


Copyright ©2018 DecSoft. All rights reserved.