From 38b8240341ea206e0720a10a30e35b34772ec9eb Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Fri, 26 Jun 2015 05:42:39 -0300 Subject: [PATCH] also try to register handlers in non-cordova environments --- src/js/init.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/js/init.js b/src/js/init.js index a0070e3f7..75e113534 100644 --- a/src/js/init.js +++ b/src/js/init.js @@ -6,6 +6,15 @@ angular.element(document).ready(function() { var startAngular = function() { angular.bootstrap(document, ['copayApp']); }; + + var handleBitcoinURI = function(url) { + if (!url) return; + setTimeout(function() { + window.location = '#/uri-payment/' + url; + }, 1000); + }; + + /* Cordova specific Init */ if (window.cordova !== undefined) { @@ -37,8 +46,7 @@ angular.element(document).ready(function() { var loc = window.location; if (loc.toString().match(/index\.html#\/$/)) { navigator.app.exitApp(); - } - else { + } else { window.location = '#/cordova/walletHome'; } }, false); @@ -53,13 +61,6 @@ angular.element(document).ready(function() { navigator.splashscreen.hide(); }, 2000); - function handleBitcoinURI(url) { - if (!url) return; - setTimeout(function() { - window.location = '#/uri-payment/' + url; - }, 1000); - } - window.plugins.webintent.getUri(handleBitcoinURI); window.plugins.webintent.onNewIntent(handleBitcoinURI); window.handleOpenURL = handleBitcoinURI; @@ -67,6 +68,13 @@ angular.element(document).ready(function() { startAngular(); }, false); } else { + + try { + window.handleOpenURL = handleBitcoinURI; + window.plugins.webintent.getUri(handleBitcoinURI); + window.plugins.webintent.onNewIntent(handleBitcoinURI); + } catch (e) {} + startAngular(); }