If you have a comment on this topic, contact Aptify Documentation. If you want to return to the Aptify Community Site, please click here.

Using Local Storage Variables and Application Key in Aptify Mobile for Members

To save the local variables throughout your application, AMM uses Local Storage. Examples used in AMM are displayed below. These variables are editable and can be configured to meet your organization's requirements.


Local Storage Declaration:

 

 var Storage = { 
 UserID: "UserID", 
 LinkID: "LinkID", 
 DisplayName: "DisplayName", 
 TokenID: "TokenID", 
 UserName: "UserName", 
 UserPassword: "UserPassword", 
 RememberMe: "RememberMe", 
 FavEvent: "FavEvent", 
 FavSession: "FavSession", 
 ActiveFeed: "ActiveFeed", 
 ResultPerPage: "ResultPerPage", 
 EventsPastYearCount: "EventsPastYearCount" 
 };

 

 

Note

 This should be mainly declared in the aptify.mobile.settings.js file

 

Creating Local Storage Variables


The following is a generic method used to create Local Storage:

 

 function CreateLocalStorage(key, value) { 
 if (typeof (localStorage) == 'undefined') { 
 alert(ErrorMessages.LocalStorageSupport); 
 } 
 else { 
 try { 
 localStorage[storageAppKey + key] = value; 
 } 
 catch (e) { 
 if (e == QUOTA_EXCEEDED_ERR) { 
 alert(ErrorMessages.LocalStorageQuotaExeed); 
 } 
 } 
 } 
 } 
 The given code is to create the Local Storage by calling the above method. 
 e.g. key= Storage.EventsPastYearCount and value="1" 
 CreateLocalStorage(Storage.EventsPastYearCount, 1);

 

 

The generic method given below is used to read the Local Storage:

 

 function ReadLocalStorage(key) { 
 if (localStorage == undefined) { 
 alert(ErrorMessages.LocalStorageSupport); 
 return false; 
 } 
 else { 
 return $.trim(localStorage[storageAppKey + key]); 
 } 
 }

 

For example, ReadLocalStorage(Storage.EventsPastYearCount)


The generic method below is used to delete the Local Storage:

 

function DeleteLocalStorage(key) { 
 delete localStorage[storageAppKey + key]; 
 } 
 The given code is to delete the Local Storage by calling the above method. 
 e.g. 
 DeleteLocalStorage (Storage.EventsPastYearCount)

 

 

Application Key

An Application key is mainly used to differentiate between two applications running on the same domain.

Application Key: var storageAppKey = "AMM";

 

Note

  This should be mainly declared in the aptify.mobile.settings.js file

 

 

Copyright © 2014-2017 Aptify - Confidential and Proprietary