From 5ed7e91adfd7d9ea10fe136a8e6f5f6f3739d8f1 Mon Sep 17 00:00:00 2001 From: Ethan Neff Date: Fri, 18 Nov 2016 15:30:46 -0800 Subject: [PATCH] fix: added onDeviceResume to testbed needed because on-background data-received did not work for Android Cordova (works for Ionic1, Ionic2, and PhoneGap) --- testbed/www/js.es6/index.js | 22 ++++++++++++++++++---- testbed/www/js/index.js | 16 +++++++++++++++- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/testbed/www/js.es6/index.js b/testbed/www/js.es6/index.js index 365580fb..2038cc37 100644 --- a/testbed/www/js.es6/index.js +++ b/testbed/www/js.es6/index.js @@ -3,14 +3,28 @@ // app var app = { - initialize: function initialize() { + initialize: function() { this.bindEvents(); }, - bindEvents: function bindEvents() { + bindEvents: function() { document.addEventListener('deviceready', this.onDeviceReady, false); + document.addEventListener('resume', this.onDeviceReady, false); }, - onDeviceReady: function onDeviceReady() { - BranchInit(true); + onDeviceReady: function() { + app.branchInit(); + }, + onDeviceResume: function() { + app.branchInit(); + }, + branchInit: function() { + // Branch debug + Branch.setDebug(true); + + // Branch initialization + Branch.initSession(function(data) { + // read deep link data on click + alert('Deep Link Data: ' + JSON.stringify(data)); + }); } }; app.initialize(); diff --git a/testbed/www/js/index.js b/testbed/www/js/index.js index b56ba0aa..cf3c0662 100644 --- a/testbed/www/js/index.js +++ b/testbed/www/js/index.js @@ -8,9 +8,23 @@ var app = { }, bindEvents: function bindEvents() { document.addEventListener('deviceready', this.onDeviceReady, false); + document.addEventListener('resume', this.onDeviceReady, false); }, onDeviceReady: function onDeviceReady() { - BranchInit(true); + app.branchInit(); + }, + onDeviceResume: function onDeviceResume() { + app.branchInit(); + }, + branchInit: function branchInit() { + // Branch debug + Branch.setDebug(true); + + // Branch initialization + Branch.initSession(function (data) { + // read deep link data on click + alert('Deep Link Data: ' + JSON.stringify(data)); + }); } }; app.initialize();