I am using **angular 7** and **ionic 5**. When i want to redirect to previous page using hardware back button, ionic app is closing itself. I am using below code but its not working.

```
 this.platform.backButton.subscribeWithPriority(9999, () => {
        document.addEventListener('backbutton', function (event) {
          event.preventDefault();
          event.stopPropagation();
          console.log('hello');
        }, false);
      });

```