...
To support uMobile's session management requirements, the project has developed a custom SessionTracking plugin using the PhoneGap plugin API. This plugin provides two methods to the front-end implementation:
- get: returns the last-accessed timestamp for the current session
- set: sets the last-accessed timestamp for the current session to the system's current time, then returns that value
The backend code associated with the SessionTracking plugin keeps an application-wide variable representing the last session access time. In Java, this is implemented as a static Long so that it may be accessed across the codebase.
Front-End Session Tracking
Each time index.html is loaded, uMobile uses the SessionTracking plugin to retrieve the last-accessed timestamp and compares it against the current time and configured session length. If the session is believed to be expired, uMobile runs the configured authentication logic to establish a new session. The SessionTracking plugin is used to update the last-accessed timestamp each time a session is established.
Back-End Session Tracking
Each The backend code associated with the SessionTracking plugin keeps an application-wide variable representing the last session access time. In Java, this is implemented as a static Long so that it may be accessed across the codebase. Each time a URL is loaded, uMobile compares the URL with the base portal path. If this URL is a portal URL, we assume that it requires and exercises a uPortal session. The code compares the current session access timestamp to the expected session length and current time to determine whether a current session already exists. If one does, the session access timestamp is updated to the current time. If If no session exists, the code aborts the current request and reloads the index.html document in the main window. This will cause the app to re-authenticate to the portal. Some module state may be lost in the process.
Android
On In Android, it appears that we can implement custom URL handling intercept web requests by extending CordovaWebViewClient . We specifically override and overriding the onLoadResource method to check each URL against a list of regexes. When we need to handle one specially, we can . In this case, we inser our session-tracking check, and if we need to reload index.html, we call ctx.loadUrl with some alternate local file URL, bypassing the normal default WebView behavior. The most practical URL to load is likely simply the main Ideally we might pass a parameter to index.html file, perhaps passing in parameters to indicate that the session must be reloaded, or that the view should be initialized to a particular local module.
...
indicating that a particular module should be loaded instead of the home screen. This method can also be used to implement the service URL handling logic described elsewhere.
iOS
// TODO
Web
To allow demoing and skin development without a mobile app emulator, the uMobile native app project offers an HTML5-based test implementation of the SessionTracker.