Device using?


#1

Hello everyone,

Is there any way to discovery which device the person is using to zap? I remember of an old function that does this and also a warning about it can be possible removed from zapworks anytime.

att, Higão.


#2

;-; anyone?


#3

Hi higor!

Do you mean iOS vs Android, or device model etc? If so I don’t believe we have a function exposed to do this at the moment but it’s a good feature request :slight_smile: Let us know which particular bits of data you’re looking for and we can see what we can rustle up!

Cheers,
Connell


#4

On Zapworks Studio you can select devices simulation to see how it looks against different devices. I believe Higor wants that information to be available in run time to set the layout based on the phone the user is using.


#5

My initial ideia with this is:

If I’ve a layout that I can’t cut it to do the RelativeTo thing, I could recognize the device and do a check like:

if(Z.device().UsingDevice("Samsung 8+")){
    //or use a controller for this what I think
    //more valid to let this function generic   
    groupAll.scale([1.2,1.2,1.2]);
}

With this simple string check, I could make my elements that I can’t cut, be adjusted to the format screen of the using device. This is very common on the notseen version of the experience.

When it comes to the screen with all the layout and etc, a very good practice is let the main group scaled to the format of a IPAD2+, so in this way the project will fits well in all other screens but in a smaller version (what I think very bad and made me think on this a couple of years back).

If this could happen would be very cool and I think beneficial for everyone who thinks about this minimal details and experience.

att, Higão.


#6

Hey @higor,

Setting this up to identify each possible device would be a significant amount of work, and could prove unmaintainable in the long term, unfortunately.

A decent workaround could be to react to the device’s aspect ratio instead. You can do so with the code snippet below:

let aspectRatio : number;
Z.screen.on("resize",(height,width)=>aspectRatio = height/width);

Please note that this wouldn’t return the device’s advertised aspect ratio, but rather the aspect ratio of the screen portion of the Zappar app i.e. not including the Zappar app UI.

You could use the returned value to activate specific states which alter the UI to suit devices with other aspect ratios.

Hope this helps. Let me know if you have any other questions.

All the best,
Seb