Search code examples
androidhybrid-mobile-appnativescript

Android webview & javaScriptInterface like functionality in NativeScript to save session token using login webpage in webview


In android if I want to use an already existing login webpage, I can use webview and javaScriptInterface to save token values after login success. Is there a similar functionality to save the token values using the pre-existing login webpage in NativeScript?


Solution

  • You can use the application settings module.

    var appSettings = require("application-settings");
    
    //Save the token
    appSettings.setString("token",token)
    
    //Retrieve token
    var token = appSettings.getString("token");
    

    Data is persistent until user uninstalls the app.