I use the following code to check iphone lock state.
int notify_token;
notify_register_dispatch("com.apple.springboard.lockstate", ¬ify_token,dispatch_get_main_queue(), ^(int token) {
uint64_t state = UINT64_MAX;
notify_get_state(token, &state);
if (state == 0)
{
// Locked
}
else
{
// Unlocked
}
});
The problem is that we get notification only if device is locked or unlocked. I want to know the current lock status. ie. I have started the app and at any point of time I want to know whether device is locked or unlocked. Using the above code we will be notified only when device is locked or unlocked by the user.
Is there any alternatives for this?