From 5ed7e91adfd7d9ea10fe136a8e6f5f6f3739d8f1 Mon Sep 17 00:00:00 2001 From: Ethan Neff Date: Fri, 18 Nov 2016 15:30:46 -0800 Subject: [PATCH 1/8] 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(); From 9cadd5d02deb2fd412ddad56d5aa61738231072e Mon Sep 17 00:00:00 2001 From: Ethan Neff Date: Fri, 18 Nov 2016 15:31:46 -0800 Subject: [PATCH 2/8] docs: updated 30mins to 15mins for AASA update to not scare off users of our potentially slow system --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b8e9d1f2..2c84db94 100644 --- a/README.md +++ b/README.md @@ -207,7 +207,7 @@ - #### Test Deep Link iOS - - Wait 30 minutes after saving changes on the [Branch Dashboard](https://dashboard.branch.io/settings/link) + - Wait 15 minutes after saving changes on the [Branch Dashboard](https://dashboard.branch.io/settings/link) - Create a deep link from the [Branch Marketing Dashboard](https://dashboard.branch.io/marketing) From 3ea7d650af4e0afc7d32a65f421bb74b04e3b8fb Mon Sep 17 00:00:00 2001 From: Ethan Neff Date: Fri, 18 Nov 2016 15:33:54 -0800 Subject: [PATCH 3/8] docs: style updates --- README.md | 159 +++++++++++++++++++++++++++--------------------------- 1 file changed, 79 insertions(+), 80 deletions(-) diff --git a/README.md b/README.md index 2c84db94..8dd05647 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ - #### Install Branch - - Change `key_live_hiuejxqEdbHR8Tc1L92nmiijrse9OBpq`, and `branchcordova` to the values in your [Branch Dashboard](https://dashboard.branch.io/settings/link) + - Change `key_live_hiuejxqEdbHR8Tc1L92nmiijrse9OBpq` and `branchcordova` to the values in your [Branch Dashboard](https://dashboard.branch.io/settings/link) -
Cordova and PhoneGap and Ionic ```sh @@ -289,18 +289,18 @@ ```js // only canonicalIdentifier is required var properties = { - canonicalIdentifier: "123", - canonicalUrl: "http://example.com/123", - title: "Content 123", - contentDescription: "Content 123 " + Date.now(), - contentImageUrl: "http://lorempixel.com/400/400", + canonicalIdentifier: '123', + canonicalUrl: 'http://example.com/123', + title: 'Content 123', + contentDescription: 'Content 123 ' + Date.now(), + contentImageUrl: 'http://lorempixel.com/400/400/', price: 12.12, - currency: "GBD", - contentIndexingMode: "private", + currency: 'GBD', + contentIndexingMode: 'private', contentMetadata: { - "custom": "data", - "testing": 123, - "this_is": true + 'custom': 'data', + 'testing': 123, + 'this_is': true } }; @@ -308,9 +308,9 @@ var branchUniversalObj = null; Branch.createBranchUniversalObject(properties).then(function(res) { branchUniversalObj = res; - alert("Response: " + JSON.stringify(res)); + alert('Response: ' + JSON.stringify(res)); }).catch(function(err) { - alert("Error: " + JSON.stringify(err)); + alert('Error: ' + JSON.stringify(err)); }); ```
@@ -435,29 +435,29 @@ ```js // optional fields var analytics = { - channel: "channel", - feature: "feature", - campaign: "campaign", - stage: "stage", - tags: ["one","two","three"] + channel: 'channel', + feature: 'feature', + campaign: 'campaign', + stage: 'stage', + tags: ['one', 'two', 'three'] }; // optional fields var properties = { - $fallback_url: "www.example.com", - $desktop_url: "www.desktop.com", - $android_url: "www.android.com", - $ios_url: "www.ios.com", - $ipad_url: "www.ipad.com", - more_custom: "data", + $fallback_url: 'www.example.com', + $desktop_url: 'www.desktop.com', + $android_url: 'www.android.com', + $ios_url: 'www.ios.com', + $ipad_url: 'www.ipad.com', + more_custom: 'data', even_more_custom: true, this_is_custom: 41231 }; branchUniversalObj.generateShortUrl(analytics, properties).then(function(res) { - alert(JSON.stringify(res.url)); + alert('Response: ' + JSON.stringify(res.url)); }).catch(function(err) { - alert(JSON.stringify(err)); + alert('Error: ' + JSON.stringify(err)); }); ``` @@ -474,23 +474,23 @@ ```js // optional fields var analytics = { - channel: "channel", - feature: "feature", - campaign: "campaign", - stage: "stage", - tags: ["one","two","three"] + channel: 'channel', + feature: 'feature', + campaign: 'campaign', + stage: 'stage', + tags: ['one', 'two', 'three'] }; // optional fields var properties = { - $fallback_url: "www.example.com", - $desktop_url: "www.desktop.com", - $android_url: "www.android.com", - $ios_url: "www.ios.com", - $ipad_url: "www.ipad.com", - more_custom: "data", + $fallback_url: 'www.example.com', + $desktop_url: 'www.desktop.com', + $android_url: 'www.android.com', + $ios_url: 'www.ios.com', + $ipad_url: 'www.ipad.com', + more_custom: 'data', even_more_custom: true, - this_is_custom: 41231 + this_is_custom: 321 }; var message = "Check out this link"; @@ -498,17 +498,17 @@ // optional listeners (must be called before showShareSheet) branchUniversalObj.onShareSheetLaunched(function(res) { // android only - alert(JSON.stringify(res)); + alert('Response: ' + JSON.stringify(res)); }); branchUniversalObj.onShareSheetDismissed(function(res) { - alert(JSON.stringify(res)); + alert('Response: ' + JSON.stringify(res)); }); branchUniversalObj.onLinkShareResponse(function(res) { - alert(JSON.stringify(res)); + alert('Response: ' + JSON.stringify(res)); }); branchUniversalObj.onChannelSelected(function(res) { // android only - alert(JSON.stringify(res)); + alert('Response: ' + JSON.stringify(res)); }); // share sheet @@ -546,9 +546,9 @@ -
Example (first data) ```js Branch.getFirstReferringParams().then(function(res) { - alert("Response: " + JSON.stringify(res)); + alert('Response: ' + JSON.stringify(res)); }).catch(function(err) { - alert("Error: " + JSON.stringify(err)); + alert('Error: ' + JSON.stringify(err)); }); ```
@@ -556,9 +556,9 @@ -
Example (latest data) ```js Branch.getLatestReferringParams().then(function(res) { - alert("Response: " + JSON.stringify(res)); + alert('Response: ' + JSON.stringify(res)); }).catch(function(err) { - alert("Error: " + JSON.stringify(err)); + alert('Error: ' + JSON.stringify(err)); }); ```
@@ -572,9 +572,9 @@ -
Example ```js branchUniversalObj.listOnSpotlight().then(function(res) { - alert(JSON.stringify(res)); + alert('Response: ' + JSON.stringify(res)); }).catch(function(err) { - alert(JSON.stringify(err)); + alert('Error: ' + JSON.stringify(err)); }); ```
@@ -588,9 +588,9 @@ -
Example ```js branchUniversalObj.registerView().then(function(res) { - alert(JSON.stringify(res)); + alert('Response: ' + JSON.stringify(res)); }).catch(function(err) { - alert(JSON.stringify(err)); + alert('Error: ' + JSON.stringify(err)); }); ```
@@ -615,7 +615,7 @@ Branch.logout().then(function(res) { alert(JSON.stringify(res)); }).catch(function(err) { - alert(JSON.stringify(err)); + alert('Error: ' + JSON.stringify(err)); }); ``` @@ -628,20 +628,20 @@ -
Example ```js - var eventName = "clicked_on_this"; - var metaData = { "custom_dictionary": 123 }; // optional + var eventName = 'clicked_on_this'; + var metaData = { custom_dictionary: 123 }; // optional Branch.userCompletedAction(eventName, metaData).then(function(res) { - alert(JSON.stringify(res)); + alert('Response: ' + JSON.stringify(res)); }).catch(function(err) { - alert(JSON.stringify(err)); + alert('Error: ' + JSON.stringify(err)); }); ``` ```js var eventName = "clicked_on_this"; Branch.userCompletedAction(eventName).then(function(res) { - alert(JSON.stringify(res)); + alert('Response: ' + JSON.stringify(res)); }).catch(function(err) { - alert(JSON.stringify(err)); + alert('Error: ' + JSON.stringify(err)); }); ```
@@ -670,37 +670,37 @@ -
Example (spend credits) ```js var amount = 10; - var bucket = "this_bucket"; // optional + var bucket = 'this_bucket'; // optional Branch.redeemRewards(amount, bucket).then(function(res) { - alert(JSON.stringify(res)); + alert('Response: ' + JSON.stringify(res)); }).catch(function(err) { - alert(JSON.stringify(err)); + alert('Error: ' + JSON.stringify(err)); }); ``` ```js var amount = 10; Branch.redeemRewards(amount).then(function(res) { - alert(JSON.stringify(res)); + alert('Response: ' + JSON.stringify(res)); }).catch(function(err) { - alert(JSON.stringify(err)); + alert('Error: ' + JSON.stringify(err)); }); ```
-
Example (load credits) ```js - var bucket = "this_bucket"; // optional + var bucket = 'this_bucket'; // optional Branch.loadRewards(bucket).then(function(res) { - alert(JSON.stringify(res)); + alert('Response: ' + JSON.stringify(res)); }).catch(function(err) { - alert(JSON.stringify(err)); + alert('Error: ' + JSON.stringify(err)); }); ``` ```js Branch.loadRewards().then(function(res) { - alert(JSON.stringify(res)); + alert('Response: ' + JSON.stringify(res)); }).catch(function(err) { - alert(JSON.stringify(err)); + alert('Error: ' + JSON.stringify(err)); }); ```
@@ -708,9 +708,9 @@ -
Example (load history) ```js Branch.creditHistory().then(function(res) { - alert(JSON.stringify(res)); + alert('Response: ' + JSON.stringify(res)); }).catch(function(err) { - alert(JSON.stringify(err)); + alert('Error: ' + JSON.stringify(err)); }); ```
@@ -748,9 +748,9 @@ ``` - **Update config.xml** - ```js + ```xml - ** + @@ -864,7 +864,7 @@ | | iOS | Details | Android | Details | --- | :-: | --- | :-: | --- | Facebook NewsFeed | ✅ | Works when [DeepViews](https://dashboard.branch.io/settings/deepviews) are enabled | ✅ | - | Facebook Messanger | ✅ | Works when [DeepViews](https://dashboard.branch.io/settings/deepviews) are enabled | ✅ | Works except the `app.link` domain is not clickable | + | Facebook Messanger | ✅ | Works when [DeepViews](https://dashboard.branch.io/settings/deepviews) are enabled | ✅ | Works except the `app.link` domain is not click-able | | Twitter | ✅ | | ✅ | | Pinterest | ✅ | Works when [DeepViews](https://dashboard.branch.io/settings/deepviews) are enabled | 🅾️ | | Slack | ✅ | | ✅ | | @@ -935,10 +935,8 @@ function DeepLinkHandler(data) { if (data) { // access the angular Factory("DeepLink") - angular.element(document.querySelector("[ng-app]")).injector().get("DeepLink").set(data); - console.log("Data Link handler response: " + JSON.stringify(data)); - } else { - console.error("Data Link handler no data"); + angular.element(document.querySelector('[ng-app]')).injector().get("DeepLink").set(data); + console.log('Data Link handler response: ' + JSON.stringify(data)); } } ``` @@ -1047,12 +1045,13 @@ - Open Android Studio -> New project -> ... -> Run -> Create new emulator -> Nexus 6p 23 -> Finish ```sh - sudo cat >> ~/.bash_profile < - -
Genymotion *(optional)* + -
Genymotion *[optional]* - Install [Virtual Box](https://www.virtualbox.org/wiki/Downloads) - Install [Genymotion](https://www.genymotion.com/download/) From cd31ebc0f7006f5930bf89599eb6eeddefaafad5 Mon Sep 17 00:00:00 2001 From: Ethan Neff Date: Fri, 18 Nov 2016 15:34:33 -0800 Subject: [PATCH 4/8] docs: changes 30mins to 15mins for AASA update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit don’t want to discourage users of our slow dashboard system --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8dd05647..014758d2 100644 --- a/README.md +++ b/README.md @@ -229,7 +229,7 @@ - #### Test Deep Link Android - - Wait 30 minutes after saving changes on the [Branch Dashboard](https://dashboard.branch.io/settings/link) + - Wait 15 minutes after saving changes on the [Branch Dashboard](https://dashboard.branch.io/settings/link) - Create a deep link from the [Branch Marketing Dashboard](https://dashboard.branch.io/marketing) From 8f71e9cd6d22efd94ddd496a3339ac39626dfb1a Mon Sep 17 00:00:00 2001 From: Ethan Neff Date: Fri, 18 Nov 2016 15:35:48 -0800 Subject: [PATCH 5/8] docs: style updates --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 014758d2..698b2d67 100644 --- a/README.md +++ b/README.md @@ -261,7 +261,7 @@ Branch.initSession().then(function(res) { console.log(res); }).catch(function(err) { - console.error(err); + alert('Error: ' + JSON.stringify(err)); }); ```
@@ -451,7 +451,7 @@ $ipad_url: 'www.ipad.com', more_custom: 'data', even_more_custom: true, - this_is_custom: 41231 + this_is_custom: 321 }; branchUniversalObj.generateShortUrl(analytics, properties).then(function(res) { @@ -601,11 +601,11 @@ -
Example (set) ```js - var userId = "email_or_id"; + var userId = 'email_or_id'; Branch.setIdentity(userId).then(function(res) { - alert(JSON.stringify(res)); + alert('Response: ' + JSON.stringify(res)); }).catch(function(err) { - alert(JSON.stringify(err)); + alert('Error: ' + JSON.stringify(err)); }); ```
@@ -677,6 +677,7 @@ alert('Error: ' + JSON.stringify(err)); }); ``` + ```js var amount = 10; Branch.redeemRewards(amount).then(function(res) { @@ -696,6 +697,7 @@ alert('Error: ' + JSON.stringify(err)); }); ``` + ```js Branch.loadRewards().then(function(res) { alert('Response: ' + JSON.stringify(res)); From b5654cb87d94f90bf8b7287ea3616971af116370 Mon Sep 17 00:00:00 2001 From: Ethan Neff Date: Fri, 18 Nov 2016 15:36:35 -0800 Subject: [PATCH 6/8] docs: 7c's for disable listener warning --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 698b2d67..9be1ec18 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ - [Link Domain: Custom](#link-domain-custom) - [Link Domain: Bnc.lt](#link-domain-bnclt) - [Link Data: Convert to Ionic/Angular](#link-data-convert-to-ionicangular) - - [Link Data: Depreciated Methods](#link-data-depreciated-methods) + - [Link Data: Global Listener Warning](#link-data-global-listener-warning) - [Compiling: Updating the Branch SDK](#compiling-updating-the-branch-sdk) - [Compiling: Cordova Dependencies](#compiling-cordova-dependencies) - [Compiling: Visual Studio TACO](#compiling-visual-studio-taco) @@ -982,11 +982,11 @@ ```
-- #### Link Data: Depreciated Methods +- #### Link Data: Global Listener Warning - - Before version `2.4.0`, Branch used globally defined listeners to pass events generated by clicking on links outside your cordova app into it. To make this behavior more explicit, we've shifted to event listeners passed to the branch object via the branch.initSession(onBranchLinkHook) and branch.onNonBranchLink(hook). If you don't want to use these new methods and instead prefer the old global hooks without seeing warnings, call branch.disableGlobalListenersWarning(). + - After Branch SDK `2.4.0`, deep link data is handled within `Branch.initSession(DeepLinkDataFunction);` - - `branch.disableGlobalListenersWarnings();` turns off warnings about using global listeners. + - Use `Branch.disableGlobalListenersWarnings();` to turn off the warning errors generated from `DeepLinkHandler` and `NonBranchLinkHandler` - #### Compiling: Updating the Branch SDK From c69ef5693f2ade2d01c3061fae1f70515063717c Mon Sep 17 00:00:00 2001 From: Ethan Neff Date: Fri, 18 Nov 2016 15:38:01 -0800 Subject: [PATCH 7/8] docs: added onDeviceResume and new DeepLinkHandler logic onDeviceResume is required for Android background (cordova only). renamed DeepLinkHandler section to deprecated --- README.md | 155 ++++++++++++++++++++++++++---------------------------- 1 file changed, 76 insertions(+), 79 deletions(-) diff --git a/README.md b/README.md index 9be1ec18..95bc3498 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,6 @@ - [Install Branch](#install-branch) - [Configure App](#configure-app) - [Initialize Branch](#initialize-branch) - - [Listen Deep Link](#listen-deep-link) - [Test Deep Link iOS](#test-deep-link-ios) - [Test Deep Link Android](#test-deep-link-android) - [Features](#features) @@ -102,29 +101,29 @@ -
Cordova and PhoneGap ```js - // sample index.js var app = { initialize: function() { this.bindEvents(); }, - bindEvents: function() { - document.addEventListener("deviceready", this.onDeviceReady, false); + document.addEventListener('deviceready', this.onDeviceReady, false); + document.addEventListener('resume', this.onDeviceReady, false); }, onDeviceReady: function() { - BranchInit(true); + app.branchInit(); }, - - function BranchInit(isDebug) { - Branch.setDebug(isDebug); // for development and debugging only - Branch.initSession().then(function(res) { - console.log(res); - }).catch(function(err) { - console.error(err); + onDeviceResume: function() { + app.branchInit(); + }, + branchInit: function() { + // Branch initialization + Branch.initSession(function(data) { + // read deep link data on click + alert('Deep Link Data: ' + JSON.stringify(data)); }); } }; - + app.initialize(); ```
@@ -132,45 +131,55 @@ -
Ionic 1 ```js // sample app.js + angular.module('starter', ['ionic', 'starter.controllers', 'starter.services']) + .run(function($ionicPlatform) { $ionicPlatform.ready(function() { + if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) { + cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); + cordova.plugins.Keyboard.disableScroll(true); + } + if (window.StatusBar) { + StatusBar.styleDefault(); + } - $ionicPlatform.on("deviceready", function(){ - BranchInit(true); + // Branch initialization + Branch.initSession(function(data) { + // read deep link data on click + alert('Deep Link Data: ' + JSON.stringify(data)); }); - - function BranchInit(isDebug) { - Branch.setDebug(isDebug); // for development and debugging only - Branch.initSession().then(function(res) { - console.log(res); - }).catch(function(err) { - console.error(err); - }); - } }); }) + // ... ```
-
Ionic 2 ```typescript // sample app.component.js + import { Component } from '@angular/core'; + import { Platform } from 'ionic-angular'; + import { StatusBar, Splashscreen } from 'ionic-native'; + import { TabsPage } from '../pages/tabs/tabs'; + + // Branch import declare var Branch; @Component({ - // ... + template: `` }) - export class MyApp { + rootPage = TabsPage; + constructor(platform: Platform) { platform.ready().then(() => { + StatusBar.styleDefault(); + Splashscreen.hide(); - // Branch - Branch.setDebug(isDebug); // for development and debugging only - Branch.initSession().then(function(res) { - console.log(res); - }).catch(function(err) { - console.error(err); + // Branch initialization + Branch.initSession(function(data) { + // read deep link data on click + alert('Deep Link Data: ' + JSON.stringify(data)); }); }); } @@ -178,33 +187,6 @@ ```
-- #### Listen Deep Link - - - `DeepLinkHandler` must be a global function and does not have to be in `index.html` - - -
Cordova and PhoneGap and Ionic - ```html - - - - - ``` -
- - #### Test Deep Link iOS - Wait 15 minutes after saving changes on the [Branch Dashboard](https://dashboard.branch.io/settings/link) @@ -252,14 +234,17 @@ -
Example ```js // for development and debugging only - Branch.setDebug(isDebug); + Branch.setDebug(true); // sync with Mixpanel if installed Branch.setMixpanelToken('your_mixpanel_token'); - // init Branch - Branch.initSession().then(function(res) { - console.log(res); + // Branch initialization + Branch.initSession(function(data) { + // read deep link data on click + alert('Deep Link Data: ' + JSON.stringify(data)); + }).then(function(res) { + alert('Response: ' + JSON.stringify(res)); }).catch(function(err) { alert('Error: ' + JSON.stringify(err)); }); @@ -520,26 +505,38 @@ - Retrieve Branch data from a deep link - - Best practice to receive data from `DeepLinkHandler` listener + - Best practice to receive data from the `listener` -
Example (listener) - > must be global functions - ```js - // required - function DeepLinkHandler(data) { - if (data) { - // window.location = "#/tab/chats/3"; // navigate to page based on data - alert("Data Link handler response: " + JSON.stringify(data)); - } - } + // Branch initialization within your deviceReady + Branch.initSession(function(deepLinkData) { + // handler for deep link data on click + alert(JSON.stringify(deepLinkData)); + }); + ``` +
- // optional - function NonBranchLinkHandler(data) { - if (data) { - alert("Non-branch link found: " + JSON.stringify(data)); - } - } + -
Example (listener) *[depreciated]* + ```html + + + + ```
From b3593e2a5852262ce3c695a69ca3ea1972af2a0b Mon Sep 17 00:00:00 2001 From: Ethan Neff Date: Fri, 18 Nov 2016 15:48:25 -0800 Subject: [PATCH 8/8] fix: updated onDeviceResume method calls in testbed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tested √ --- testbed/www/js.es6/index.js | 37 +++++++++---------------------------- testbed/www/js/index.js | 35 +++++++++-------------------------- 2 files changed, 18 insertions(+), 54 deletions(-) diff --git a/testbed/www/js.es6/index.js b/testbed/www/js.es6/index.js index 2038cc37..cbb3b89c 100644 --- a/testbed/www/js.es6/index.js +++ b/testbed/www/js.es6/index.js @@ -1,7 +1,4 @@ -'use strict'; - // app - var app = { initialize: function() { this.bindEvents(); @@ -11,51 +8,35 @@ var app = { document.addEventListener('resume', this.onDeviceReady, false); }, onDeviceReady: function() { - app.branchInit(); + BranchInit(true); }, 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)); - }); + BranchInit(true); } }; app.initialize(); // branch - function BranchInit(isDebug) { console.log('Trigger BranchInit()'); // for development and debugging only Branch.setDebug(isDebug); - // sync with mixpanel if installed + // sync with Mixpanel if installed Branch.setMixpanelToken('your_mixpanel_token'); - // init - Branch.initSession(BranchLinkData).then(function(res) { + // Branch initialization + Branch.initSession(function(data) { + // read deep link data on click + console.log('Trigger DeepLinkHandler()'); + alert('Deep Link Data: ' + JSON.stringify(data)); + }).then(function(res) { console.log(res); }).catch(function(err) { console.error(err); }); - // handler for deep link data - function BranchLinkData(data) { - console.log('Trigger BranchLinkData()'); - - if (data) { - alert(JSON.stringify(data)); - } - } - // optional Branch.onNonBranchLink(function NonBranchLinkHandler(data) { console.log('Trigger NonBranchLinkData()'); diff --git a/testbed/www/js/index.js b/testbed/www/js/index.js index cf3c0662..8b1dff21 100644 --- a/testbed/www/js/index.js +++ b/testbed/www/js/index.js @@ -1,7 +1,6 @@ 'use strict'; // app - var app = { initialize: function initialize() { this.bindEvents(); @@ -11,51 +10,35 @@ var app = { document.addEventListener('resume', this.onDeviceReady, false); }, onDeviceReady: function onDeviceReady() { - app.branchInit(); + BranchInit(true); }, 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)); - }); + BranchInit(true); } }; app.initialize(); // branch - function BranchInit(isDebug) { console.log('Trigger BranchInit()'); // for development and debugging only Branch.setDebug(isDebug); - // sync with mixpanel if installed + // sync with Mixpanel if installed Branch.setMixpanelToken('your_mixpanel_token'); - // init - Branch.initSession(BranchLinkData).then(function (res) { + // Branch initialization + Branch.initSession(function (data) { + // read deep link data on click + console.log('Trigger DeepLinkHandler()'); + alert('Deep Link Data: ' + JSON.stringify(data)); + }).then(function (res) { console.log(res); }).catch(function (err) { console.error(err); }); - // handler for deep link data - function BranchLinkData(data) { - console.log('Trigger BranchLinkData()'); - - if (data) { - alert(JSON.stringify(data)); - } - } - // optional Branch.onNonBranchLink(function NonBranchLinkHandler(data) { console.log('Trigger NonBranchLinkData()');