Skip to content

Instantly share code, notes, and snippets.

@VojtechBartos
Last active August 29, 2015 14:15
Show Gist options
  • Save VojtechBartos/d1e6d42b08977669309f to your computer and use it in GitHub Desktop.
Save VojtechBartos/d1e6d42b08977669309f to your computer and use it in GitHub Desktop.
Branch.IO
<html>
<head>
<title>Branch IO test</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript">
(function() {
var config = {
app_id: '<app_id>',
debug: true,
init_callback: function(){
console.log('Branch SDK initialized!');
}
};
// Begin Branch SDK //
var Branch_Init=function(e){var t=this;t.app_id=e.app_id,t.debug=e.debug,t.init_callback=e.init_callback,t.queued=[],t.init=function(){for(var e=["close","logout","track","identify","createLink","showReferrals","showCredits","redeemCredits","appBanner"],n=0;n<e.length;n++)t[e[n]]=function(e){return function(){t.queued.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(e[n])},t.init();var n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src="https://bnc.lt/_r",document.getElementsByTagName("head")[0].appendChild(n),t._r=function(){if(void 0!==window.browser_fingerprint_id){var e=document.createElement("script");e.type="text/javascript",e.async=!0,e.src="https://s3-us-west-1.amazonaws.com/branch-web-sdk/branch-0.2.x.min.js",document.getElementsByTagName("head")[0].appendChild(e)}else window.setTimeout(function(){t._r()},100)},t._r()};window.branch=new Branch_Init(config);
// End Branch SDK //
$(document).ready(function() {
// just create link
$('#createLink').click(function() {
$('#link').html('Loading');
branch.createLink({
channel: 'web',
feature: 'jawbone app opening',
state: 'registered',
type: 0,
data: {
user_id: 7266,
firstName: 'Vojta',
last_name: 'Bartos',
email: 'vojta+branchio@sleepio.com',
'$desktop_url':
'http://www.sleepio.com/iphone/download/',
'$ios_url': 'https://itunes.apple.com/app/id910208298'
}
}, function(data) {
$('#link').html(function(){
return $('<a>').attr('href', data).html(data);
});
});
});
// open link directly
var link = null;
branch.createLink({
channel: 'web',
feature: 'jawbone app opening',
state: 'registered',
type: 0,
data: {
firstName: "brandon",
'$desktop_url': 'http://www.sleepio.com/iphone/download/',
'$ios_url': 'https://itunes.apple.com/app/id910208298'
}
}, function(data) {
$('#link').html(function(){
return $('<a>').attr('href', data).html(data);
});
});
});
})();
</script>
</head>
<body>
<button id="createLink">
Create link
</button>
<div id="link">
Loading
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment