On Device Platform
Last updated
Last updated
This is deprecated in Rock Mobile V6 and later. for .NET MAUI.
In some cases, it can be useful to customize content or appearance across platforms—for example, applying one style on Android and a different one on iOS to match each platform's native aesthetic. This extension provides a way to set content or property values depending on the device's OS platform.
Below is legacy documentation for the original Rock:OnDevicePlatform
extension.
Android
object
The value to be used when the device is running on Android.
iOS
object
The value to be used when the device is running on iOS.
Default
object
The value to be used when the device is running on something else.
When running on an Android device, the text will be blue. If instead running on an iOS device then the text will be red. Otherwise, the text will be black. While not currently required, the Default value should be specified in case we add other platforms in the future.
Here is a more interesting example. In this case, we are replacing not just a property but an entire element. On Android, they will see a button that they can tap. On every other platform, they will see a label that informs them the feature only works on Android.