Search code examples
cordovaipadios9

Cordova iOS Go Back To Previous Page


I am not very familiar with iOS. I have a Cordova app that I built and it runs fine on Android. However when I run it on an iPad running iOS 9 there are no back buttons to travel back to the previous page like any browser I have ever used in my life. I'm assuming its loaded into a UIWebView so how am I supposed to travel back to the previous page when there is no back button?


Solution

  • You will need to create a custom "backButton" equivalent to Android or Windows Phone native back buttons.

    In my case, I created an "Arrow to Left" button in left top corner of the screen to work as backButton. After, I linked my backButton function for Android e WP to it. Look:

    HTML:

    <span id="iosBackButton" ng-click="iosBackButtonEvent()"><i class='fa fa-chevron-left'></i>&nbsp;Back</span>
    

    JS:

    //Android and WP cordova handle
    //document.addEventListener('backbutton', backButtonActions, false);
    
    //Only iOS
    $scope.iosBackButtonEvent= function() {
            try {
                backButtonActions();
            }
            catch (error) {
                console.log(error);
            }
        };
    

    PS: I use AngularJS.