Any idea to redirect to index page when launch app from URL SCHEMA?


#1

Hi,

I implement a Custom-URL-scheme plugin for my ionic app.

background:
I launch the app by the url scheme when the app is running on background.
So the app will redirect to index page rather than stay on the current page before go to background.

issue:
I can tracker the event of launch the app from the URL scheme by the global function “handleOpenURL”.
But it will redirect after animation…

Can It redirect to the index page before render the view??

So that the user will not see the redirect animation.

#I am working with IOS#
#Thanks…a lot#

Current state:

Current app.js:

(function () {

    var app = angular.module('mainApp', ['ionic',
        'helper.urlschema',
        'xxx.navigationView',
        'xxx.mainSideMenuView',
        'xxx.firstPage',
        'xxx.secondPage'
    ]);


    app.config(function ($stateProvider, $urlRouterProvider) {
        $urlRouterProvider.otherwise('/xxx/firstPage');
    });

    app.controller('mainViewsController', function ($scope, $state) {

        $scope.launchFromURL = function (url) {
            console.log("is launch from url: " + url);
            alert("from URL: " + url);
            $state.go("indexpage")

        };
    });

    app.run(function ($ionicPlatform) {
        $ionicPlatform.ready(function () {

            if (window.cordova && window.cordova.plugins.Keyboard) {
                cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
            }
            if (window.StatusBar) {
                StatusBar.styleDefault();
            }
        });
    })

}());

function handleOpenURL(url) {
    var body = document.getElementsByTagName("body")[0];
    var scope = angular.element(body).scope();
    setTimeout(function () {
        scope.launchFromURL(url);
    }, 0);
}