UNPKG

cordova.plugin.googleplus

Version:

Use your Google account to authenticate with the app.

101 lines (88 loc) 3.12 kB
<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <meta name="format-detection" content="telephone=no"/> <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height"/> <link rel="stylesheet" type="text/css" href="css/index.css"/> <meta name="msapplication-tap-highlight" content="no"/> <title>Hello World</title> </head> <body> <div class="app"> <img id="image" style="position:absolute; top:10px; left:10px" src="" /> <h1>Google+</h1> <div id="deviceready" class="blink"> <p class="event listening">Connecting to Device</p> <p class="event received">Device is Ready</p> <p id="feedback">not logged in</p> <button onclick="isAvailable()">Available?</button> <br/><br/> <button onclick="login()">Login with Google+</button> <br/><br/> <button onclick="trySilentLogin()">Try silent login with Google+</button> <br/><br/> <button onclick="logout()">Logout</button> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <button onclick="disconnect()">Disconnect</button> <br/><br/> </div> </div> <script type="text/javascript" src="cordova.js"></script> <script type="text/javascript" src="js/index.js"></script> <script type="text/javascript"> app.initialize(); function isAvailable() { window.plugins.googleplus.isAvailable(function(avail) {alert(avail)}); } function login() { window.plugins.googleplus.login( {}, function (obj) { document.querySelector("#image").src = obj.imageUrl; document.querySelector("#image").style.visibility = 'visible'; document.querySelector("#feedback").innerHTML = "Hi, " + obj.displayName + ", " + obj.email; }, function (msg) { document.querySelector("#feedback").innerHTML = "error: " + msg; } ); } function trySilentLogin() { window.plugins.googleplus.trySilentLogin( {}, function (obj) { document.querySelector("#image").src = obj.imageUrl; document.querySelector("#image").style.visibility = 'visible'; document.querySelector("#feedback").innerHTML = "Silent hi, " + obj.displayName + ", " + obj.email; }, function (msg) { document.querySelector("#feedback").innerHTML = "error: " + msg; } ); } function logout() { window.plugins.googleplus.logout( function (msg) { document.querySelector("#image").style.visibility = 'hidden'; document.querySelector("#feedback").innerHTML = msg; } ); } function disconnect() { window.plugins.googleplus.disconnect( function (msg) { document.querySelector("#image").style.visibility = 'hidden'; document.querySelector("#feedback").innerHTML = msg; } ); } window.onerror = function(what, line, file) { alert(what + '; ' + line + '; ' + file); }; function handleOpenURL (url) { document.querySelector("#feedback").innerHTML = "App was opened by URL: " + url; } </script> </body> </html>