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


Eduardo Alfaro

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.decsoftutils.com/Humm/Sites/Main/Views/Data/AppBuilder/Help/en-US/tutorialCordovaPlugins.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


DecSoft

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...



Ade Wale

Hi Eduardo,

Did you get itablet working on your device?

AB rock!


Eduardo Alfaro

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


DecSoft

Hello to all!

Anyone here are tried with the UserAgent action? :)



Guest

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


DecSoft
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?


Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.

This website uses some useful cookies to store your preferences.

I agree. Hide this note. Give me more information.