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"))))
Solved! Go to Solution.
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).
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).
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?
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?
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));
You're right.
I think I was using locally IsBrowser and renamed it.
Sorry for that
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?).
An exceptional idea !!!
User | Count |
---|---|
197 | |
122 | |
89 | |
48 | |
41 |
User | Count |
---|---|
285 | |
162 | |
138 | |
80 | |
73 |