Shake-to-Refresh is a reusable OutSystems Mobile block that detects intentional phone movement and exposes an OnShake event. Applications can use this event to refresh lists, dashboards, notifications, offline queues, or other screen data.
OnShake
Motion sensors may not work correctly in browser preview. Native device features need to be tested in a generated mobile application.
ShakeToRefresh
Add the block to any mobile screen where shake detection is required.
Enabled
True
Threshold
18
CooldownMilliseconds
1200
MinimumIntervalMilliseconds
80
Enabled = True Threshold = 18 CooldownMilliseconds = 1200 MinimumIntervalMilliseconds = 80
Sensitivity guidance:
12–16 More sensitive 18–22 Normal sensitivity 25+ Less sensitive
If the component triggers too easily, increase Threshold.
If the component does not detect a normal shake, decrease Threshold.
Triggered when the component detects a shake.
The event has no output parameters.
Example:
ShakeToRefresh.OnShake → RefreshData
The consuming application is responsible for defining the refresh behavior.
RefreshData
Phone shake ↓ ShakeToRefresh.OnShake ↓ RefreshData ↓ Reload screen data
Create a client action:
Inside the action:
Set IsRefreshing = True Reload data Update screen variables Set IsRefreshing = False
For an Aggregate-based screen, refresh the Aggregate or call the relevant data-loading client action.
For an API-based screen, call the server action that retrieves the latest data.
The component starts listening when the block is initialized:
Block OnInitialize ↓ StartListening
It removes the sensor listener when the block is destroyed:
Block OnDestroy ↓ StopListening
Listener cleanup is important because it prevents:
The component detects movement through:
window.DeviceMotionEvent
It uses the device’s acceleration values on the X, Y, and Z axes to calculate movement intensity.
A shake is triggered when the movement change exceeds the configured Threshold.
The cooldown prevents a single physical shake from generating several events.
Some iOS environments may require explicit user permission before motion data can be accessed.
Always provide a normal refresh button:
Refresh button.OnClick → RefreshData
The fallback is required because:
Try the following:
Enabled = True
14
Increase:
For example:
CooldownMilliseconds = 2000
Also confirm that StopListening is called from the block’s OnDestroy lifecycle event.
StopListening
OnDestroy
Threshold = 22
You can also implement multi-peak detection, requiring two movement peaks within a short time window.
Check: