28
Views
5
Comments
Solved
how to handle the mobile back button to logout the app
Question

Hi 


I was try mobile back button to logout the screen. I used this java script 

Steps to follow:

1) Include the dialogs plugin as the Extensibility Configurations property value for the application module as shown below (Or define the dialogs plugin as an isolated application module)

{    "plugin":     {        "url": "https://github.com/apache/cordova-plugin-dialogs.git"    }}

2) Under the Logic Tab, introduce OnApplicationReady Systems event

3) Within the OnApplicationReady action flow, introduce a JS node with the below script

JS Snippet:

function goToPreviousScreen(button) {

  if (button == 1) {

      history.back(); // go to previous screen, if presses "Yes"

  } else {

    return false; // No action, if presses "cancel"

  }

}


function onBackButtonClick() {

  document.addEventListener(

    "backbutton",

    function (e) {

      navigator.notification.confirm(

        "Are you sure you want to leave the screen?",

        goToPreviousScreen,

        "Warning",

        "Yes, Cancel"

      ); // you can change the button names in the place of Yes, Cancel.

    },

    false

  );

}


if ($actions.CheckDialogsPlugin()) {

  onBackButtonClick();

}

but As I want to logout the page but this code used for previous page. have any solution for my problem. I was attach my OML file also

backbutton.oml
2024-07-12 05-57-50
Gourav Shrivastava
Champion
Solution

Hello @Palani Bharathi ,

You can use the Android back button forge component, which helps you handle back-button events on every page you can make a handler of block event and add your logic of what you want to do if the back button clicks on that particular screen.

Let me know if I am not able to understand the question.

Thanks 

Regards Gourav Shrivastava

UserImage.jpg
Md Mansur

Hi @Palani Bharathi 

I have attached Link so go through this link:

https://www.outsystems.com/forums/discussion/56573/exit-back-button-in-android/

Thanks

Mansur  

UserImage.jpg
Palani Bharathi

have any OML file for my reference?


UserImage.jpg
Palani Bharathi

I was go through the link and executed but not working 

I have attached the OML file. please check it and let me know...

TestingMobileApp.oml
2024-07-12 05-57-50
Gourav Shrivastava
Champion
Solution

Hello @Palani Bharathi ,

You can use the Android back button forge component, which helps you handle back-button events on every page you can make a handler of block event and add your logic of what you want to do if the back button clicks on that particular screen.

Let me know if I am not able to understand the question.

Thanks 

Regards Gourav Shrivastava

UserImage.jpg
Lavanya A

Hi, 
For mobile Back button issue refer this post it has a Solution.
How to Exit App when Back button is pressed in mobile app | OutSystems 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.