Detecting whether device is locked or unlocked

I know Ionic has the feature to detect if it is running in the background or not. But is there any way the app can detect if the phone or device is locked or unlocked? This would help with a safety feature I want to implement to detect if the person is moving with the device being unlocked.