Proximity Sensor Plugin is an OutSystems 11 mobile plugin that provides access to the device's proximity sensor.
The component allows mobile applications to:
The plugin uses the native device capabilities provided through a Cordova proximity sensor plugin.
The underlying Cordova plugin supports:
The component has been tested on Android.
iOS support is provided by the underlying Cordova plugin and should be validated on the target iOS environment before production use.
Note: Proximity sensor availability and behavior can vary depending on the device hardware and operating system.
This component is intended for:
The proximity sensor cannot be properly tested using the browser preview because it depends on native device capabilities.
Install Proximity Sensor Plugin from Forge and add it as a dependency to your OutSystems 11 mobile application.
After adding the component, you can use the exposed Client Actions directly from your mobile application logic.
Because this component uses a native mobile plugin, changes to the native plugin configuration require a new mobile application build.
Simply publishing the application logic is not sufficient when the native plugin configuration changes.
The component provides four Client Actions:
CheckProximityAvailability
EnableProximitySensor
DisableProximitySensor
GetProximityState
Checks whether the proximity sensor plugin is available in the current mobile application.
IsAvailable — Boolean
True
False
Call:
Then check:
IsAvailable = True
before attempting to use the proximity sensor.
Enables the device proximity sensor and starts proximity monitoring.
Success — Boolean
Indicates whether the sensor was successfully enabled.
ErrorMessage — Text
Contains the error message when the operation fails.
Success = True
If the operation fails, use:
ErrorMessage
to identify the problem.
Disables the device proximity sensor and stops proximity monitoring.
Indicates whether the sensor was successfully disabled.
Retrieves the current state of the device's proximity sensor.
IsNear — Boolean
Indicates whether the proximity state was successfully retrieved.
Then:
If(IsNear, "Object is near", "Object is far" )
A typical implementation can follow this sequence:
CheckProximityAvailability ↓ IsAvailable? ↓ Yes ↓ EnableProximitySensor ↓ GetProximityState ↓ Use IsNear in application logic ↓ DisableProximitySensor
You can implement the following flow:
IsNear
GetProximityState returns the current proximity state when it is called.
If your application needs to continuously monitor the sensor, you can call GetProximityState periodically using an OutSystems Timer.
For example:
Timer ↓ GetProximityState ↓ Update IsNear ↓ Repeat
For most use cases, a reasonable polling interval should be selected based on the application's requirements rather than continuously polling at a very high frequency.
The IsNear output is a Boolean value.
IsNear = True
An object is detected close to the proximity sensor.
Hand → 📱 NEAR
IsNear = False
No object is detected close to the proximity sensor.
Hand 📱 FAR
The exact detection distance depends on the device's proximity sensor hardware.
When the proximity sensor detects an object nearby, the device may automatically dim the screen or change screen interaction behavior.
This behavior is controlled by the device's operating system and may vary depending on the device and platform.
This behavior is not controlled by the OutSystems component.
The component has been tested on an Android physical device.
The tested flow includes:
On the tested Android device, the screen dims when an object is placed near the proximity sensor.
The underlying Cordova plugin supports iOS.
However, iOS behavior can differ from Android depending on the device and operating system.
On iOS, the proximity sensor can affect screen brightness and touch interaction when the sensor detects a nearby object.
The component has not been independently validated on an iOS physical device, so applications targeting iOS should test the component on their target devices before production deployment.
A Proximity Sensor Demo application is included with the component.
The demo demonstrates:
Use:
and verify that:
Also verify that the application is running on a physical device that contains a proximity sensor.
Make sure the sensor has first been enabled:
Then call:
This can be expected behavior when the proximity sensor detects a nearby object. The behavior is controlled by the mobile operating system.
Because this is a native mobile plugin, generate and install a new mobile build after making changes to the native plugin configuration. Native plugin changes require a new application package.
IsAvailable
Success
This component uses the Cordova Proximity Sensor Plugin as its underlying native plugin.
The underlying plugin is distributed under the Apache License 2.0. Its original license and attribution are retained in the plugin repository.