cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JimmyWork
Power Participant
Power Participant

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 II
Helper II

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

JimmyWork
Power Participant
Power Participant

@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

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,063)