Cant get offline mode working in my app => logging in immediately results in the login screen again

1
Because part of my app needs to be used without internet connection i have created a few pages for this. First I created them as phone-browser. Then I upgraded them to phone-hybrid-online. There they work properly.  I created the android package and it works well on my phone. I can login and get the functionality as expected.   To go offline I then copied the navigation profile from online to offline and I rebuild the app in the sandbox.  Then I generated a customizable build package.  Now  the documentation tells me to locate the file index.html and open it in an editor. Find the line containing "var enableOffline=False;".etc.  My index.html doesnt contain that text. Instead settings.json contain the following: {  "url": "https://avrapp.mxapps.io",   "enableOffline": true,   "requirePin": false,   "updateAsync": false,   "username": "",   "password": "" } When i create the package with these settings and install it in my phone the following happens: when connected to the internet: I am able to login, but immediately i am returned to the login page again.  (when entering an incorrect userid/password it fails correctly so that is not the issue) The log gives only these two lines:  18:04:15 APP INFO Client: Starting the client 18:04:17 APP INFO Client: Running afterNavigation function   when not connected to the internet the app opens the login page, but my login fails with userid/password invalid....   My questions: Where should I look for the index.html with the "enable offline=true" setting?  Or has that been replaced by the JSON config file? (modeler 7.16) What could explain the returning to the login page instead of the  homepage opening?  How would the login work if offline?  Any other suggestions welcome..   [EDIT  25-7] Although not flawless it is working with the anonymous login disabled for the whole app. Still i need a landing page for anonymous users.  So still figuring out how to get the customized login working with offline app enabled...  
asked
2 answers
2
  • Where should I look for the index.html with the "enable offline=true" setting?  Or has that been replaced by the JSON config file? (modeler 7.16)
    • That's correct - the settings.json file is the new approach.
  • What could explain the returning to the login page instead of the homepage opening? 
    • Are you seeing the standard login page or one you modeled? Any chance the user you log in as doesn't have access to his home page or something? Do you have the same problem if you use the Mendix Mobile app to access your app?
  • How would the login work if offline? 
    • It wouldn't the first time - you need to log in and sync first once before you actually go offline. Then the app should keep you logged in for subsequent use
answered
2

With the help of Satomi Uematsu (thanks for that!) I found the offline-capable version of the HTML Snippet widget.

I added that to my custom (phone) login page with the suggested javascript. 

if(('localStorage' in window) && (window.localStorage !== null)) {
    delete window.localStorage.session;
} else {}

if(('sessionStorage' in window) && (window.sessionStorage !== null)) {
    sessionStorage.clear();
    window.sessionStorage.clear();
} else {}

Using an anonymous login page with the default authentication widgets (7.11)  it is not needed to use the login-form widget from the appstore or it's offline capable version. 

Then I (re) enabled anonymous use of the app and now it functions as expected. 

Ready for the next challenge...understanding the synching to and from the server data....

 

 

answered