cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Kudo Kingpin
Kudo Kingpin

Detect web browser users

Hi All,

I understand that the SaveData data and Load data funcations are currently only supported on studio and moble. I would like to detect whether users are studio or mobile so I can avoid these functions when using the web browser. How can i go about doing this.

Currently im using this but it isnt really working.

Set(IsBrowser, !IsEmpty(Errors(SaveData(testCollection, "TestSave")))) 

 

16 REPLIES 16
Highlighted

Hi guys, here is my solution...

In my case, I just needed my app to know which device it was running on between browser and mobile app, and then display a popup if it is running on mobile. So what I did was this: 

 

  OnVisible (screen):  // triger //

ClearCollect(collName, true);    // here I created a collection with a single value: true //
SaveData(collName, "fileName");   // try to save that collection wich doesn't work on a browser, just mobile app //
Clear(collName);        // delete the value I collected previously //
LoadData(collName, "fileName",true);   // try to load the data to an emptied collection, if it doesn't load it is because we aren't on mobile //
If( !IsEmpty(collName),  "do what i want")      // finally, check if the data was loaded corectly and only do the action that i want if so //

This is just a simple idea that worked for me, hopefully, it can be of help to you guys. 

Highlighted
Anonymous
Not applicable

Use this bit of code, the easiest way to check if the device is mobile or not...

 

Set(vrblMobileDevice, If(Location.Altitude > 0 Or Acceleration.X > 0, true, false));

 

Make sure you run this on the 1st screen in OnVisible ... DON'T run it on AppStart ... it's hit and miss in that section. Trust me, I've wasted over an hour on this so you don't have to.

Highlighted

Is this still accurate we really don't have native checks to determine mobile vs desktop without using a workaround such as the proposed methods which will give the  user of the app a message that location needs to be approved to use this app.  

Highlighted

As far as I am aware there is still no native check. I guess this is because Power Apps are supposed to be 'write-once, run-anywhere' so it should not matter what platform you are on, but the reality is that there are different capabilities and behaviours, so an ability to check would be useful. Some scenarios where this would be helpful:

1. Determine if running on web browser so you know whether you can persist data with SaveData/LoadData

2. Know if you are on iOS as the numeric keypad on some versions does not contain a decimal place

3. Know if you are on a mobile device when you want the ability to dial a number or send a text

4. For sending texts, know if you are on iOS or Android as you have to format the text differently for each (haven't checked recently if this is still the case)

5. Know if you are using the Windows App Player as the behaviour of the on-screen keyboard differs from other platforms and often obscures the fields in which you are trying to enter data (I guess that is not an issue any more as the Windows App Player has been all but abandoned)

Highlighted

Paul thanks for the feedback.

 

Another reason mobile can't open up SharepointGallery.Selected.'{Link}')  however can open SharepointGallery.Selected.'{Thumbnail}'.Large which is potentially significant lower resolution.  


We are using the work-around to have the higher resolution open in desktop however this creates the location approval popup when they first run the app which makes some employees paranoid.

 

If(varMobileOrDesktop = "Mobile", ImageGallery.Selected.'{Thumbnail}'.Large, ImageGallery.Selected.'{Link}')

Highlighted

This is great solutions but they all seem to fail when you add the app to Microsoft Teams.

Acceleration won't work on mobile device if you access the app using Teams tab.

 

Anyone that has a workaround to make it work in a Teams tab to?

Highlighted
Power Participant
Power Participant

@ehg Do you have a workaround for making this work in a Teams tab? It works but it displays a error message.
This error message is only displayed if the app is added to a Teams tab and not in a browser.

 

JimmyWork_0-1601290733389.png

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (9,004)