cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JimmyWork
Super User
Super User

Check if device has Acceleration.X navigate to new app, from new app navigate back and disable checking for Acceleration.X

This might sound weird but I'm trying to check if the user is on a mobile device.

If the user is on a mobile device i will Launch a new app automatically, sending the user to the mobile device app.

 

The above I can achieve by doing the following.

App: OnStart
Set(IsMobileDevice, !IsBlank(Acceleration.X))

Screen1: OnVisble
If(IsMobileDevice = true, Launch("https://apps.powerapps.com/play/xxxxxxxxxxxxxxxxxxxxxxxx",{}, 
LaunchTarget.Replace));

 

When the user now is in the mobile app i want to have a button that takes the user out of the mobile app back to the first app, but I need to disable the app1 from checking the Acceleration.X, if I don't disable that i create a loop.

 

I have tried to pass variables from the app2 (Mobile app) but i fail at creating the logic to stop the app1 from checking if the device is mobile again. 

 

I understand i need to set a variable that disables my part where I set the Acceleration.X, but I'm not sure how to achive this in a good way.

1 ACCEPTED SOLUTION

Accepted Solutions

The advantage of using the Load Data and Save Data is that you are sure that it will work even if your user kill the powerapps app during the process. And also that you dont need to add extra "unnecessary" parameters to the url.

 

The usage of those functions are similar to the Set and UpdateContext functions.
You save the value if it's not yet defined in a variable using 

SaveData(IsMobileDevice, true/false)

and you set it using : 

LoadData(IsMobileDevice, "IsMobileDevice")

If IsMobileDevice = Blank() then you save it and you proceed with the rest of the process and if not, directly proceed.

 

Clement

View solution in original post

4 REPLIES 4
carfup
Helper III
Helper III

Hello,

 

Here is an idea (to be tested), if you set a variable and then you launch a new app, this variable will be reset as soon as you go back to app1.
Idea would be to use the local cache data (LoadData / SaveData) :

  1. Open app 1
  2. Check the local cache for the variable IsMobileDevice using LoadData
  3. If variable found => skip the check and redirect
  4. If variable not found => do the check and store the result in the local cache of the app using SaveData

Clément

@carfup Thank you for answering

 

I'm not really sure I understand the solution. I have never used LoadData function before.

To clarify it.

 

App1 currently always checks if device is mobile and sets the variable, would this not mean that the variable is always available in LoadData?

App: OnStart
Set(IsMobileDevice, !IsBlank(Acceleration.X))

This solution seems to work but again I'm not sure if this is the best way of doing it.

 

App1

App: OnStart
Set(varCheckDevice, Param("VariableID"));
If(varCheckDevice = Blank(), Set(IsMobileDevice, !IsBlank(Acceleration.X)));

Screen1: OnVisible
If(IsMobileDevice = true, Launch("https://apps.powerapps.com/play/xxxxxxxxxxxxxxx",{}, 
LaunchTarget.Replace));

App2 

Button: OnSelect
Launch("https://apps.powerapps.com/play/xxxxxxxxxxxx",{VariableID: "Hello"}, 
LaunchTarget.Replace)

 

By doing this the as long as the VariableID is Blank it will check the device and forward the user to the mobile device, if the mobile device user do not want to use the mobile device screen they click the button witch takes them back to App1 and sets the VariableID to "Hello" then App1 won't check the IsMobileDevice.

The advantage of using the Load Data and Save Data is that you are sure that it will work even if your user kill the powerapps app during the process. And also that you dont need to add extra "unnecessary" parameters to the url.

 

The usage of those functions are similar to the Set and UpdateContext functions.
You save the value if it's not yet defined in a variable using 

SaveData(IsMobileDevice, true/false)

and you set it using : 

LoadData(IsMobileDevice, "IsMobileDevice")

If IsMobileDevice = Blank() then you save it and you proceed with the rest of the process and if not, directly proceed.

 

Clement

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Kudoed Authors
Users online (2,049)