In the final step of our flow, we add a 'Respond to a PowerApp flow' action to return the variable that contains the user agent.
Calling the flow to retrieve the User Agent from Power Apps
From Power Apps we can now call our flow to retrieve the user agent string.
the Action > Power Automate menu item, we add our flow. Assuming
that the name of our flow is GetPowerAppsUserAgent, we can use the
following formula to call the flow and to store the user agent in a
Power Apps variable called varUserAgent.
screenshot beneath shows how to attach this formula to the OnSelect
property of a button. We could equally attach this to the OnVisible
property of a screen, or the OnStart property of an app. The label beneath shows the user agent string that the flow retrieves.
Retrieving the browser name from the User Agent
After we retrieve the user agent string, we can write string manipulation formula to extract the browser name. Here's an example that uses the algorithm from the Stack Overflow post from above.
If("edge" in ua, "MS Edge (legacy)",
If("edg" in ua, "MS Edge (Chromium)",
If(("opr" in ua) And !("window.opr" in ua) , "Opera",
If(("chrome" in ua) And !("window.chrome" in ua) , "Chrome",
If("trident" in ua, "Internet Explorer",
If("firefox" in ua, "Firefox",
If("safari" in ua, "Safari",
no direct way to retrieve the browser, OS, or device from within a running Power
App. A workaround is to retrieve the user agent from the trigger body of
a flow, and to return it to Power Apps through a 'Respond to a PowerApp
flow' action. We can then parse the output to determine these details.