cancel
Showing results for 
Search instead for 
Did you mean: 

Hybrid Mobile App Logout Functionality

poornamamatha
Participant
0 Kudos

Hi Team,

I have created a UI5 app in WEB IDE Full stack, enabled it as Hybrid Mobile App. App is working fine now I want to implement the logout functionality for Hybrid App, after registration the user logins to the app using the logout button the user has to be logout from the App.

Please suggest your thoughts.

Regards,

Mamatha

Accepted Solutions (0)

Answers (1)

Answers (1)

Gowtham
Contributor
0 Kudos

Hi,

Following code can be used for logout functionally in fiori based Hybrid mobile applications , after successful execution of this method , navigate the screen to login page.

sap.Logon.core.deleteRegistration(jQuery.proxy(
	this.onDeleteRegistrationSuccess, this), jQuery.proxy(
	this.onLogonError, this));

Thanks

poornamamatha
Participant
0 Kudos

Hi Gowtham,

Thanks for your Response. I have tried the code that you had suggested it is not navigating to the login page so I have made some modifications to your code as shown below:

Logout: function() { if(sap.hybrid.kapsel.appContext) { sap.Logon.core.deleteRegistration( function(result) { console.log("unregister result: " + JSON.stringfy(result)); sap.hybrid.kapsel.appContext = null; sap.Logon.core.loadStartPage(); }, function(errObj) { console.error("doDeleteRegistration() Error"); }); } else{ console.log("Cannot delete Context"); } }

This code works when I click on logout it is navigating to the login page and at the same time the registered user count has decreased by 1 in SMP under User Registrations for the App.

But the problem here is after logout when I login again I am getting the below error:

By clicking on "ok" getting no data in some screens metadata is not getting loaded in online mode.

Any ideas with this error. Can you please help me out.

Regards,

Mamatha

Parriagadam
Discoverer
0 Kudos

Hi Mamatha,

Your code has an error, please use JSON.stringify instead.

console.log("unregister result: " + JSON.stringfy(result))