Created
September 27, 2015 08:51
-
-
Save tzmartin/325a180649044ca519de to your computer and use it in GitHub Desktop.
Example deep links for Branch.io - Stolen from beme.codes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<link rel="shortcut icon" href="http://beme.com/icon.png"> | |
<link rel="apple-itouch-icon" href="http://beme.com/icon.png"> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>beme.codes</title> | |
<script> | |
function is_iphone(){ | |
return !! navigator.userAgent.match(/iPhone|iPod/i); | |
} | |
function access_code(){ | |
// until page is live, allow code in query string | |
if (window.location.search) { | |
return window.location.search.replace(/\W+/g, ''); | |
} | |
return window.location.pathname.split("/")[1].replace(/\W+/g, ''); | |
} | |
function deeplink_path(){ | |
return "codes/" + access_code(); | |
} | |
function base64_encode_unicode(str){ | |
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) { | |
return String.fromCharCode('0x' + p1); | |
})); | |
} | |
function branch_data(){ | |
return { | |
"unlock_code": access_code(), | |
"$deeplink_path": deeplink_path() | |
}; | |
} | |
function generate_branch_link(){ | |
var data = branch_data(); | |
data_str = JSON.stringify(data); | |
data_str = base64_encode_unicode(data_str); | |
return "https://bnc.lt/a/key_live_pdoIoFk3XCURK1ESKXD8EoddqAbpf8Aq?data=" + data_str; | |
} | |
</script> | |
<style type="text/css"> | |
body { | |
margin: 0; | |
padding: 0; | |
background: #161616; | |
font-family: "Akkurat-Light", sans-serif; | |
font-size: 18px; | |
color: #777; | |
} | |
::selection { | |
background: #54f245; | |
color: #00eb00; | |
} | |
#container { | |
margin: 0 auto; | |
max-width: 370px; | |
} | |
#icon { | |
margin: 50px auto; | |
width: 175px; | |
height: 175px; | |
background: top center no-repeat transparent url('/icon.png'); | |
background-size: cover; | |
} | |
.state { | |
margin: 0 auto; | |
width: 70%; | |
text-align: center; | |
} | |
.button-wrapper { | |
margin: 40px auto; | |
} | |
.button { | |
background: #242424; | |
color: #919191; | |
text-decoration: none; | |
text-transform: uppercase; | |
border: 2px solid #5c5c5c; | |
border-radius: 5px; | |
padding: 15px 20px; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="container"> | |
<div id="icon"></div> | |
<div class="state" id="loading"> | |
Loading... | |
</div> | |
<div class="state" id="desktop" style="display:none"> | |
Open this page on your iPhone. | |
</div> | |
<script> | |
if (is_iphone()) { | |
if (access_code()) window.location = generate_branch_link(); | |
} else { | |
document.getElementById('loading').style.display = 'none'; | |
document.getElementById('desktop').style.display = 'block'; | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment