Ranzit
Ranzit

Reputation: 1347

Redirect to Ionic app from link clicked from InAppbrowser opened html pages

I am using cordova InAppbrowser plugin to open pages from ionic app. I have used this ccavenue payment page links in inAppbrowser. There is cancellation/redirection url in ccavenue which will get back to html page which is opening in inAppbrowser. I want to get back to ionic mobile app page when clicked on link in redirected html page. I am using CustomURLScheme plugin for this. But it is working only from normal browser view , not from InAppBrowser page view.

Here is the error I am getting :

net:ERR_UNKNOWN_URL_SCHEME

I have used/changed intent filters in Android Manifest files , config.xml files for allow origins etc as well , but no use . Can you please help in this.

Upvotes: 0

Views: 1129

Answers (1)

Ranzit
Ranzit

Reputation: 1347

I have tried with InAppBrowser loadstop and loadstart methods to open , redirect: Here is the loadstop code

$rootScope.$on('$cordovaInAppBrowser:loadstop', function (e, event) {

                    if (event.url == 'actionurl') {
                      $cordovaInAppBrowser.close();
                          $timeout(function () {   
                      $ionicHistory.clearCache();
                      $ionicHistory.clearHistory();
                      $ionicHistory.nextViewOptions({ disableAnimate: true,disableBack: true , historyRoot: true});
                          $state.go('redirect url', {}, { reload: true });
                        }, 30);

                        }

                         else if(event.url == 'actionurl'){
                      $cordovaInAppBrowser.close();
                          $timeout(function () {   
                      $ionicHistory.clearCache();
                      $ionicHistory.clearHistory();
                      $ionicHistory.nextViewOptions({ disableAnimate: true,disableBack: true , historyRoot: true});
                          $state.go('redirect url', {}, { reload: true });
                        }, 30);

                        }

      }); 

It worked well

Upvotes: 1

Related Questions