also try to register handlers in non-cordova environments

This commit is contained in:
Matias Alejo Garcia 2015-06-26 05:42:39 -03:00
commit 38b8240341

View file

@ -6,6 +6,15 @@ angular.element(document).ready(function() {
var startAngular = function() { var startAngular = function() {
angular.bootstrap(document, ['copayApp']); angular.bootstrap(document, ['copayApp']);
}; };
var handleBitcoinURI = function(url) {
if (!url) return;
setTimeout(function() {
window.location = '#/uri-payment/' + url;
}, 1000);
};
/* Cordova specific Init */ /* Cordova specific Init */
if (window.cordova !== undefined) { if (window.cordova !== undefined) {
@ -37,8 +46,7 @@ angular.element(document).ready(function() {
var loc = window.location; var loc = window.location;
if (loc.toString().match(/index\.html#\/$/)) { if (loc.toString().match(/index\.html#\/$/)) {
navigator.app.exitApp(); navigator.app.exitApp();
} } else {
else {
window.location = '#/cordova/walletHome'; window.location = '#/cordova/walletHome';
} }
}, false); }, false);
@ -53,13 +61,6 @@ angular.element(document).ready(function() {
navigator.splashscreen.hide(); navigator.splashscreen.hide();
}, 2000); }, 2000);
function handleBitcoinURI(url) {
if (!url) return;
setTimeout(function() {
window.location = '#/uri-payment/' + url;
}, 1000);
}
window.plugins.webintent.getUri(handleBitcoinURI); window.plugins.webintent.getUri(handleBitcoinURI);
window.plugins.webintent.onNewIntent(handleBitcoinURI); window.plugins.webintent.onNewIntent(handleBitcoinURI);
window.handleOpenURL = handleBitcoinURI; window.handleOpenURL = handleBitcoinURI;
@ -67,6 +68,13 @@ angular.element(document).ready(function() {
startAngular(); startAngular();
}, false); }, false);
} else { } else {
try {
window.handleOpenURL = handleBitcoinURI;
window.plugins.webintent.getUri(handleBitcoinURI);
window.plugins.webintent.onNewIntent(handleBitcoinURI);
} catch (e) {}
startAngular(); startAngular();
} }