-
Notifications
You must be signed in to change notification settings - Fork 101
/
example-deepview.html
143 lines (132 loc) · 4.66 KB
/
example-deepview.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Branch Metrics Web SDK Example App</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<style type="text/css">
.btn {
margin-top: 5px;
}
.example-input {
width: 125px;
display: inline-block;
margin-top: 5px;
vertical-align: middle;
}
.radio-input {
margin-right: 10px !important;
margin-left: 20px !important;
}
.row {
margin-bottom: 30px;
}
</style>
</head>
<body>
<div class="container">
<div class="row col-lg-8 col-lg-offset-2">
<h2>Branch Metrics Web SDK Deepview Example</h2>
</div>
<section>
<div class="row col-lg-8 col-lg-offset-2">
<h4>Session Info</h4>
<pre class="info">Reading session from .init()...</pre>
<br>
<h4>Request</h4>
<pre class="request">Click a button!</pre>
<br>
<h4>Response</h4>
<pre class="response">Click a button!</pre>
</div>
</section>
<section>
<div class="row col-lg-8 col-lg-offset-2">
<h3>Methods</h3>
<hr>
<h4>Session and Identity</h4>
<div class="group">
<button id="init" class="btn btn-success">.init()</button>
<button id="deepview" class="btn btn-info">.deepview()</button>
<button id="deepviewCta" class="btn btn-info">.deepviewCta()</button>
</div>
</div>
</section>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script type="text/javascript">
(function(b,r,a,n,c,h,_,s,d,k){if(!b[n]||!b[n]._q){for(;s<_.length;)c(h,_[s++]);d=r.createElement(a);d.async=1;d.src="dist/build.min.js";k=r.getElementsByTagName(a)[0];k.parentNode.insertBefore(d,k);b[n]=h}})(window,document,"script","branch",function(b,r){b[r]=function(){b._q.push([r,arguments])}},{_q:[],_v:1},"addListener applyCode autoAppIndex banner closeBanner closeJourney creditHistory credits data deepview deepviewCta first getCode init link logout redeem referrals removeListener sendSMS setBranchViewData setIdentity track validateCode trackCommerceEvent logEvent disableTracking getBrowserFingerprintId crossPlatformIds lastAttributedTouchData setAPIResponseCallback".split(" "), 0);
branch.setAPIResponseCallback(function(url, method, requestBody, error, status, responseBody) {
console.log('Request: ' + method + ' ' + url + ' body=' + JSON.stringify(requestBody));
if (error) {
console.log('Response: Error ' + error + '; status ' + JSON.stringify(status) + ' body=' + JSON.stringify(responseBody));
}
else {
console.log('Response: status ' + JSON.stringify(status) + ' body=' + JSON.stringify(responseBody));
}
});
// Note that this example is using the key in two places, here and below
branch.init('key_live_feebgAAhbH9Tv85H5wLQhpdaefiZv5Dv', function(err, data) {
document.getElementsByClassName('info')[0].innerHTML = JSON.stringify(data);
});
</script>
<script type="text/javascript">
var info = $('.info');
var request = $('.request');
var response = $('.response');
var sampleParams = {
tags: [ 'tag1', 'tag2' ],
channel: 'sample app',
feature: 'create link',
stage: 'created link',
type: 1,
data: {
mydata: 'bar',
'$desktop_url': 'https://cdn.branch.io/example.html',
'$og_title': 'Branch Metrics',
'$og_description': 'Branch Metrics',
'$og_image_url': 'http://branch.io/img/logo_icon_white.png'
}
};
var getInputVal = function(inputID) {
var inputElement = $(inputID);
if (!inputElement.val()) {
inputElement.parent().addClass('has-error');
return '';
}
else {
inputElement.parent().removeClass('has-error');
}
return inputElement.val();
};
$('#init').click(function() {
request.html('branch.init();');
// Note that this example is using the key in two places, here and above
branch.init('key_live_feebgAAhbH9Tv85H5wLQhpdaefiZv5Dv', function(err, data) {
response.html(err || JSON.stringify(data));
});
});
$('#deepview').click(function() {
branch.deepview(
{
'channel': 'mobile_web',
'feature': 'deepview',
data : {
'$deeplink_path': 'page/1234',
'user_profile': '7890',
'page_id': '1234',
'custom_data': 1234
}
},
{
'open_app': true
}
);
});
$('#deepviewCta').click(function() {
branch.deepviewCta();
});
</script>
</body>
</html>