Digitally transforming large
Enterprises
Making AI applied for
Enterprises
Customers Want A 360 °
Omni-Channel Retail Experience.
Seamless & Connected
Omni-Channel Experience Delivered.
Comprehensive Solution to Securely Expose Protected Resources as APIs
Offline storage allows you to post data locally in case network is not available and syncs it with server later when network is available. This is useful in many scenarios e.g. if your user is playing a game and has scored something on completion of a specific level. However, at the time of posting of score if network is not available his score might get lost and his efforts will go waste. This can be avoided using offline caching where his score will be saved locally in case of network unavailability and will be later synced with server when network availability resumes.
// Enabling offline storage. App42API.SetOfflineStorage (true);
You can also configure the number of records for offline storage using the below code:
// Enabling offline storage with no. of max requests to be saved. // By default no. of max requests is 100. App42API.SetOfflineStorage (true, 20);
//Set Offline Storage to True App42API.SetOfflineStorage (true); String gameName = "<Enter_your_game/level_name>"; String userName = "Nick"; double gameScore = 3500; scoreBoardService.SaveUserScore(gameName, userName, gameScore, new UnityCallBack()); public class UnityCallBack : App42CallBack { public void OnSuccess(object response) { if (response is App42OfflineResponse) { //Request is saved in cache Debug.Log("Information is Stored in cache, will send to App42 when network is available"); } else { Game game = (Game) response; Debug.Log("gameName is " + game.GetName()); for(int i = 0;i<game.GetScoreList().Count;i++) { Debug.Log("userName is : " + game.GetScoreList()[i].GetUserName()); Debug.Log("score is : " + game.GetScoreList()[i].GetValue()); Debug.Log("scoreId is : " + game.GetScoreList()[i].GetScoreId()); } } } public void OnException(Exception e) { App42Log.Console("Exception : " + e); } }
The expected behaviour of above code is that if network is available it give response from server and if network is not available response comes locally.