Use Cordova in javascriptsnippet in page

1
Hello, I want to redirect from a native app to an URL using the cordova browser. The reason is to remote logout from the Active Directory server and clear the locally stored tokens. To do this, I use the following JavaScript in a JavaScript (DataSource) widget on the logout page (after I have killed the user session). try{ // Perform any custom operations on the dojoConfig object here // var cordova = require("cordova"); var oauthLogout = function() { console.log("Functie starten"); var oauthWindow = cordova.InAppBrowser.open("${RedirectURL}", "_blank", "location=no,toolbar=no"); var exitFn = function(){ navigator.app.exitApp(); }; oauthWindow.addEventListener("exit", exitFn); var cb = function(event) { console.log("Redirect uitvoeren"); // if (event.url.indexOf(window.mx.remoteUrl) == 0 && event.url.indexOf("${RedirectURL}") == -1) { oauthWindow.removeEventListener("loadstop", cb); oauthWindow.removeEventListener("exit", exitFn); oauthWindow.executeScript({ code: "document.cookie;" }, function(values) { window.localStorage.clear(); oauthWindow.close(); }); } oauthWindow.addEventListener("loadstop", cb); } console.log("gaan"); oauthLogout(); console.log("gedaan"); }catch(e){ console.log(e.message); window.localStorage.clear(); console.log("${RedirectURL}"); top.location.href = "${RedirectURL}"; } The code generates the following exception: “cordova is not defined” When I add “var cordova = require("cordova");” I get an undefinedModule exception. The same with var cordova = require("cordova.js"); and var cordova = require("./cordova.js");   Does somebody have any idea how I can use Cordova from this point?    
asked
1 answers
0

Are you using a link or a redirect widget at any point while using the hybrid app? I ask because these methods cause the app's “browser” window to navigate away from the local index.html page that is built into the hybrid app. When that happens, you lose the Cordova API and all native device capabilities.

answered