cordova-plugin-powermanagement
cordova-plugin-powermanagement copied to clipboard
Plugin doesn't work in iOS
@Viras- I want Screen always wake-up in iOS, so I'm integrating power management Cordova plugin for iOS.
After Create cordova project for iOS, I added this plugin. (cordova plugin add https://github.com/Viras-/cordova-plugin-powermanagement.git)
and put this code in my script but plugin code is not works for me.
Here is my code:
<script type="text/javascript">
document.addEventListener("deviceready", onDeviceReady, false);
//function will be called when device ready
function onDeviceReady()
{
var isDeviceiOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
if(isDeviceiOS)
{
if(window.localStorage.getItem('keepscreenonchkboxlocal') == "true")
{
isIdleTimerDisabled = true;
}
else
{
isIdleTimerDisabled = false;
}
}
else
{
if(window.localStorage.getItem('keepscreenonchkboxlocal') == "true")
{
window.powerManagement.acquire(function() {
console.log('Wakelock acquired');
}, function() {
console.log('Failed to acquire wakelock');
});
}
else
{
window.powerManagement.release(function() {
console.log('Wakelock released');
}, function() {
console.log('Failed to release wakelock');
});
}
}
}
</script>
This cordova plugin works in android but doesn't works in ios.
Thanks, Kaushik.
if(isDeviceiOS)
{
// iOS - no window.powerManagement in here?
}
else
{
// Android - window.powerManagement _is_ here...
}
Doesn't look like you're using the plugin on iOS, am I reading that right?