Cordova/Ionic2 | How To Lock And Unlock Screen Of Android And IOS?

- 1 answer

I just want to find a plugin that can trigger the native device screen lock button. So for example if you click a button your device gets locked just it would do if you click your devices native lock button on the side of the phone. For example if your lock button of the device is broken you could do this within an app.

As far as I can tell the only plugin that would work is this one: . But it seems it only works for android (And might aswell only lock the screen orientation).

window.screenLocker.unlock(successCallback, errorCallback, 10);  // 10 seconds unlock timeout (third parameter is optional)
window.screenLocker.lock(successFun, errorFun);  // release screen unlock

Is there any solution for iOS aswell? I really cant find anything.



There is a very good reason why the plugin is android-only, as there is no public API to lock the screen on iOS. In general, Apple is more restrictive as to what it allows its developers to do.

For a more in depth explanation, check out this answer.