I have index.html where I have deviceready
event listener added to script tag. But it is not triggered on loading the HTML. Instead, when clicking the home button it is triggered from onAppDidEnterBackground
method in CDVViewController
.
I wanted to call my custom plugin to get the values which I am trying to populate in the HTML loaded. I found few solutions asking to change the meta tag. I did try changing, but no use. It is not working in iOS9 also. I guess the meta tag issue is from iOS10. I am not sure what I am missing here.
Cordova v4.4.0
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: http://* 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<title>My HTML Document</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src='cordova.js'></script>
<script type="text/javascript" src='CustomPlugin.js'></script>
<script>
document.addEventListener('deviceready', function () {
window.plugins.CustomPlugin.myMethod(function (result) {
document.getElementById('Name').value = result['Name'];
}, function (error) {
alert(error);
});
}, false);
</script>
</head>
<body>
<div class='article'>
<div class='tableWrapper'>
<table>
<tr>
<td class='right'>CName:</td>
<td colspan='3'><input type='text' id='Name'/></td>
</tr>
</table>
</div>
</div>
</body>
</html>