Search code examples
iosibm-mobilefirsthybrid

why is isCustomResponse is not called the second time?


I define a Challenge Handler,

var AuthRealmChallengeHandler = WL.Client.createChallengeHandler("AuthRealm");

AuthRealmChallengeHandler.isCustomResponse = function(response) {
    //returns true or false
};

once I click the login button i send a request to the adapter:

var resourceRequest = new WLResourceRequest(
            "/adapters/AuthAdapter/getSecretData", WLResourceRequest.GET,
            30000);
resourceRequest.send().then(getSecretData_CallbackOK,
            getSecretData_CallbackFail);

However, after closing the app, re-launching and the login button is pressed again, the isCustomResponse is not called again. Why is it so?

I've checked that the isUserAuthenticated returns true, however it still doesn't call isCustomResponse:

WL.Client.updateUserInfo();

if (WL.Client.isUserAuthenticated("AuthRealm")) {

}else{

}

Solution

  • In addition to changing the project settings as was mentioned in the comments, to answer the remaining questions:

    • There is no relation between the application session "state" to JSONStore. JSONStore is local to your app itself in the device and not to the network.

    • You can invoke the logout function on application initialization, as a way to ensure that the client will be logged out once you have re-started the app in order to simulate the expected behavior by you. You will likely also want to extend the splash screen duration while this action is done so the user experience will be better... the logout function needs to simply call WL.Client.logout (refer to the documentation for this).