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

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")))) 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Power Apps
Power Apps

Re: Detect web browser users

From what I'm seeing here that's happening because SaveData does not return an error, so your logic would be broken.

I'm not sure if there's a best approach, but you can get unblocked with this:


Set(IsSaveDataSupported, !(CountRows(SaveData(["1", "2"],"myTestList").Value)=2))

 

I've put this on first screen's OnStart and that worked fine.

Hope it helps

 

Please, keep in mind that SaveData might change its behavior in the future (e.g., to return an Error). 

View solution in original post

16 REPLIES 16
Highlighted
Power Apps
Power Apps

Re: Detect web browser users

From what I'm seeing here that's happening because SaveData does not return an error, so your logic would be broken.

I'm not sure if there's a best approach, but you can get unblocked with this:


Set(IsSaveDataSupported, !(CountRows(SaveData(["1", "2"],"myTestList").Value)=2))

 

I've put this on first screen's OnStart and that worked fine.

Hope it helps

 

Please, keep in mind that SaveData might change its behavior in the future (e.g., to return an Error). 

View solution in original post

Highlighted
Community Champion
Community Champion

Re: Detect web browser users

This is going to help me out a lot!

 

Can I get a clarification though, @claudiosvcc.

 

Set(IsSaveDataSupported, !(CountRows(SaveData(["1", "2"],"myTestList").Value)=2))

If I understand correctly, this means, "Check if myTestList returns 2 rows. If SaveData returns 2, the ! in red means take the opposite of that, so the variable returns false. If it doesn't return 2, the ! causes the variable to return true." I assume @AnthonyPhan wants the variable to return true if SaveData does not work, so this makes sense.

 

I am confused because with the NOT (!), the name of the variable may be mismatched. Would the variable be more appropriately named something like "IsSaveDataNotSupported"? Or did I misunderstand the formula logic?

 

Microsoft Employee
@8bitclassroom
Highlighted
Kudo Commander
Kudo Commander

Re: Detect web browser users

Hi @mr-dang

Your understanding of the logic is correct. The variable could be better named as "IsSaveDataNotSupported".

 

@claudiosvcc Another thing worth mentioning is on start you will recieve an error message in web browser mode. Is there any way to hide this to improve the user experience for the browser users?

image.png

Highlighted
Advocate II
Advocate II

Re: Detect web browser users

@claudiosvcc I have the same issue. Is it possible to hide this error message? 

 

Thanks

Highlighted
Kudo Commander
Kudo Commander

Re: Detect web browser users

Hi @FredTherrien

I found that for my purposes checking if there are any accelerometer readings was a work around. Within my organisation all mobile devices had accelerometers and all desktop device did not. By checking this instead of saveData I was able to throw no error and accuratly differentiate between devices

 

Set(IsSaveDataSupported, !IsBlank(Acceleration.X));
Highlighted
Power Apps
Power Apps

Re: Detect web browser users

You're right.

I think I was using locally IsBrowser and renamed it.

Sorry for that

Highlighted
Advocate II
Advocate II

Re: Detect web browser users

Thanks @AnthonyPhan this is a great workaround!

Highlighted
Advocate II
Advocate II

Re: Detect web browser users

For anyone else that comes across this thread and is looking to use @AnthonyPhan's suggestion (many thanks Anthony), I ran into an issue (maybe its with the latest version) whereas:

 

Set(IsSaveDataSupported, !IsBlank(Acceleration.X))

occasionally sets IsSaveDataSupported = false on my mobile device when the formula is set on the OnStart function of the first screen of the app.  I actually found it inconsistent with each open of the app it may be true or it may be false seemingly randomly.  However, when I put a (500ms AutoStart AutoPause) Timer on the first screen, and set the OnTimerEnd function to the same formula it consistently returns true on my mobile and false on the web (as expected).  It appears that Acceleration.X is sometimes blank right at the startup of the app (maybe it takes a moment for the accelerometer to be enabled?).

Highlighted
Solution Sage
Solution Sage

Re: Detect web browser users

An exceptional idea !!!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (7,284)