Skip to content

Commit

Permalink
[CHORE] Updated testbed app
Browse files Browse the repository at this point in the history
  • Loading branch information
Renemari Padillo committed Jan 18, 2016
1 parent 22bff45 commit a34fc95
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 178 deletions.
7 changes: 7 additions & 0 deletions testbed/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Branch.IO SDK Testbed App

### How to run:

* Simple run the `init.sh` file

* Run the app by executing the following command `cordova run <platform>`, eg: `cordova run android`
115 changes: 18 additions & 97 deletions testbed/www/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,100 +16,21 @@
* specific language governing permissions and limitations
* under the License.
*/
* {
-webkit-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */
}

body {
-webkit-touch-callout: none; /* prevent callout to copy image, etc when tap to hold */
-webkit-text-size-adjust: none; /* prevent webkit from resizing text to fit */
-webkit-user-select: none; /* prevent copy paste, to allow, change 'none' to 'text' */
background-color:#E4E4E4;
background-image:linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
background-image:-webkit-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
background-image:-ms-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%);
background-image:-webkit-gradient(
linear,
left top,
left bottom,
color-stop(0, #A7A7A7),
color-stop(0.51, #E4E4E4)
);
background-attachment:fixed;
font-family:'HelveticaNeue-Light', 'HelveticaNeue', Helvetica, Arial, sans-serif;
font-size:12px;
height:100%;
margin:0px;
padding:0px;
text-transform:uppercase;
width:100%;
}

/* Portrait layout (default) */
.app {
background:url(../img/logo.png) no-repeat center top; /* 170px x 200px */
position:absolute; /* position in the center of the screen */
left:50%;
top:50%;
height:50px; /* text area height */
width:225px; /* text area width */
text-align:center;
padding:180px 0px 0px 0px; /* image height is 200px (bottom 20px are overlapped with text) */
margin:-115px 0px 0px -112px; /* offset vertical: half of image height and text area height */
/* offset horizontal: half of text area width */
}

/* Landscape layout (with min-width) */
@media screen and (min-aspect-ratio: 1/1) and (min-width:400px) {
.app {
background-position:left center;
padding:75px 0px 75px 170px; /* padding-top + padding-bottom + text area = image height */
margin:-90px 0px 0px -198px; /* offset vertical: half of image height */
/* offset horizontal: half of image width and text area width */
}
}

h1 {
font-size:24px;
font-weight:normal;
margin:0px;
overflow:visible;
padding:0px;
text-align:center;
}

.event {
border-radius:4px;
-webkit-border-radius:4px;
color:#FFFFFF;
font-size:12px;
margin:0px 30px;
padding:2px 0px;
}

.event.listening {
background-color:#333333;
display:block;
}

.event.received {
background-color:#4B946A;
display:none;
}

@keyframes fade {
from { opacity: 1.0; }
50% { opacity: 0.4; }
to { opacity: 1.0; }
}

@-webkit-keyframes fade {
from { opacity: 1.0; }
50% { opacity: 0.4; }
to { opacity: 1.0; }
}

.blink {
animation:fade 3000ms infinite;
-webkit-animation:fade 3000ms infinite;
}
h1,h2,h3,
h4,h5,h6, p {
margin: 0;
word-wrap: break-word; }
.status--info {
margin: 10px 0; }
.app {}
.logo {
width: 100px;
margin: auto;
text-align: center; }
.logo img {
width: 100%; }
.title {
margin-bottom: 15px;
text-align: center; }
.success {
color: rgb(0, 255, 0); }
24 changes: 18 additions & 6 deletions testbed/www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,28 @@
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<link rel="stylesheet" type="text/css" href="css/index.css">
<title>Branch.IO TestBed</title>
<title>Branch.IO SDK TestBed</title>
</head>
<body>
<div class="app">
<h1>Apache Cordova</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
<div class="logo">
<img src="img/logo.png" />
</div>
<h2 class="title">Branch.IO SDK Testbed</h2>
<div class="status">
<div class="status--info">
<h4>Status</h4>
<p>Initializing...</p>
</div>
<div class="status--info">
<h4>First Params</h4>
<p>Fetching data...</p>
</div>
<div class="status--info">
<h4>Latest Params</h4>
<p>Fetching data...</p>
</div>
</div>
<div id="content"></div>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
Expand Down
145 changes: 70 additions & 75 deletions testbed/www/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,93 +33,88 @@ var app = {
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
app.receivedEvent('deviceready');
app.receivedEvent('app');
},
// Update DOM on a Received Event
receivedEvent: function(id) {

setTimeout(function () {
console.log('Getting installation details');
Branch.initSession().then(function (res) {

Branch.setDebug(true).then(function (res) {
console.log('Set debug: ' + res);
});

Branch.getFirstReferringParams().then(function (res) {
console.log('Get first referring params: ');
console.log(res);
});
var parentElement = document.getElementById(id);

Branch.getLatestReferringParams().then(function (res) {
console.log('Get getLatestReferringParams: ');
console.log(res);
});
console.log('Received Event: ' + id);

console.log('Getting installation details');

Branch.createBranchUniversalObject({
"canonicalIdentifier" : "sample-id",
"title" : "Sample",
"contentDescription" : "This is a sample",
"contentImageUrl" : "http://sample-host.com/media/1235904.jpg",
"contentIndexingMode" : "private",
"contentMetadata" : {
"key" : "value",
"key2" : "value2"
}
}).then(function (branch) {
Branch.initSession().then(function (initRes) {

// Set app initSession success
var initStatusDOM = document.getElementsByClassName('status--info');
initStatusDOM[0].childNodes[3].innerHTML = 'Branch SDK Init Success';
initStatusDOM[0].childNodes[3].className += ' success';

console.log('createBranchUniversalObject');
branch.generateShortUrl({
"feature" : "sample-feature",
"alias" : "sample-alias",
"channel" : "sample-channel",
"stage" : "sample-stage"
}, {
"$desktop_url" : "http://desktop-url.com",
}).then(function (link) {
console.log('Generate Short Url');
console.log(link);
});
Branch.getFirstReferringParams().then(function (res) {
console.log('Get first referring params: ');
console.log(res);
initStatusDOM[1].childNodes[3].innerHTML = JSON.stringify(res);
});

console.log('RegisterView');
branch.registerView();
Branch.getLatestReferringParams().then(function (res) {
console.log('Get getLatestReferringParams: ');
console.log(res);
initStatusDOM[2].childNodes[3].innerHTML = JSON.stringify(res);
});

console.log('Share Sheet');
branch.showShareSheet({
"feature" : "sample-feature",
"alias" : "sample-alias",
"channel" : "sample-channel",
"stage" : "sample-stage",
"duration" : 1,
}, {
"$desktop_url" : "http://desktop-url.com"
});
// Branch.createBranchUniversalObject({
// "canonicalIdentifier" : "sample-id",
// "title" : "Sample",
// "contentDescription" : "This is a sample",
// "contentImageUrl" : "http://sample-host.com/media/1235904.jpg",
// "contentIndexingMode" : "private",
// "contentMetadata" : {
// "key" : "value",
// "key2" : "value2"
// }
// }).then(function (branch) {

});
// console.log('createBranchUniversalObject');
// branch.generateShortUrl({
// "feature" : "sample-feature",
// "alias" : "sample-alias",
// "channel" : "sample-channel",
// "stage" : "sample-stage"
// }, {
// "$desktop_url" : "http://desktop-url.com",
// }).then(function (link) {
// console.log('Generate Short Url');
// console.log(link);
// });

var content = document.getElementById('content');
content.innerHTML = res;

// Branch.creditHistory().then(function (res) {
// console.log('Credit history:');
// console.log(res);
// }, function (err) {
// console.log(err);
// });
// console.log('RegisterView');
// branch.registerView();

}, function (err) {
console.error(err);
});
}, 300);
// console.log('Share Sheet');
// branch.showShareSheet({
// "feature" : "sample-feature",
// "alias" : "sample-alias",
// "channel" : "sample-channel",
// "stage" : "sample-stage",
// "duration" : 1,
// }, {
// "$desktop_url" : "http://desktop-url.com"
// });

},
// Update DOM on a Received Event
receivedEvent: function(id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
// });

// Branch.creditHistory().then(function (res) {
// console.log('Credit history:');
// console.log(res);
// }, function (err) {
// console.log(err);
// });

listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
}, function (err) {
console.error(err);
});

console.log('Received Event: ' + id);
}
};

Expand Down

0 comments on commit a34fc95

Please sign in to comment.