Capacitor how to trigger forward button click?

Viewed 31

I have ionic 5 with capacitor in angular project to deploy app as cross-platform.In android devices I'd like to manipulate back and forward button/swipe clicks in case at least one modal is active.App should go back if there is no active modal otherwise modal should be closed only without navigating user.To do that I did implementation in appComponent as below which is working perfectly for back button.

import { App } from '@capacitor/app';

  App.addListener('backButton', () => {
        if (this.activeModalInstance) {
               this.activeModalInstance.close();
            }
             else {
               this._location.back();
             } 
      });

Unfortunately on forward button or swipe action this 'backButton' is working and navigating back since I have location.back() inside.I need to figure out how to determine either back or forward applied.How can I do this?

0 Answers
Related