Hi,
I am trying to determine if my PCF component should render in mobile layout or a web layout. I did not want to use the allocatedWidth and allocatedHeight to determine the layout as this may be a hit or miss and we cannot set a valid threshold to choose a layout (mobile or web) in all scenarios.
However, I found the Client.getFormFactor() and Client.getClient() methods and thought that may be the solution. But I can't seem to understand these API in PCF.
When creating a Canvas app in a Mobile layout in Power Apps Web client, the getClient() returns "Web" and getFormFactor() returns 1. When will the getClient() return "Mobile" and getFormFactor() return 3 (for Phone)?
https://docs.microsoft.com/en-us/power-apps/developer/component-framework/reference/client
Hi @mapguy2006 ,
The Canvas App "mobile layout" it's just a setup for the size of the screen.
The client.getClient() tells you where the app is running. As long you call the Canvas App in the webBrowser, you will always get "Web". When the Canvas App is running inside a Mobile App you'll get "Mobile".
So the same App, will have the client.getClient() "Web" when the app is running in the browser, and will be "Mobile" if the app is running in Power Apps Mobile (iPhone, Android App or Power Apps for Windows).
The "client.getFormFactor" will tell you what device is used.
WarrenBelz
89
Most Valuable Professional
Michael E. Gernaey
72
Super User 2025 Season 1
mmbr1606
71
Super User 2025 Season 1