We are developing an app for Cordova. It will authenticate against Azure AD, and we are using the ADAL library for Cordova. To test this is working, we did a proof of concept, and thas was all working fine.

When testing it in our “production” app, it did not work. When kicking off the authentication with this code:

var ctx = new Microsoft.ADAL.AuthenticationContext(authority);
ctx.acquireTokenAsync(resourceUrl, appId, redirectUrl).then(function (authRes) {

… it did no longer work on Android. On Windows 8.1 it was fine. On Android it opened a new window for the authentication screen, but it was stuck at “Loading”. Nothing in the JavaScript console either. So, I stripped all the includes out of the HTML, until I finally had the identical HTML + JS as the working proof of concept.

So, it must be something in the Android settings. I compared them, and it turned out “Keep running” was turned off in the “Production” app, and turned on in the working POC. I enabled that and now it is working… This setting can be found by opening config.xml => Android. In the XML it is:

<preference name=”KeepRunning” value=”True” />