|
<!DOCTYPE html> |
|
<html> |
|
<head> |
|
<meta charset="utf-8"> |
|
<title>Branch.io Smart Banner</title> |
|
<script type="text/javascript"> |
|
var ratingCount, averageUserRating, appID, branchKey; |
|
appID = "284882215"; |
|
branchKey = "YOUR_API_KEY" |
|
function getRating(content) { |
|
ratingCount = content.results[0].userRatingCount; |
|
averageUserRating = content.results[0].averageUserRating; |
|
branch.init(branchKey, function(err, data) { |
|
// callback to handle err or data |
|
}); |
|
branch.banner( |
|
{ |
|
icon: 'https://cdn0.iconfinder.com/data/icons/social-flat-rounded-rects/512/facebook-256.png', |
|
title: 'Facebook', |
|
description: 'Facebook, you know what it is already.', |
|
openAppButtonText: 'Open', |
|
downloadAppButtonText: 'Install', |
|
phonePreviewText: '999-999-9999', |
|
sendLinkText: 'Txt me a link!', |
|
showDesktop: true, |
|
showiOS: true, |
|
showAndroid: false, |
|
iframe: true, |
|
theme: 'dark', |
|
rating: averageUserRating, |
|
reviewCount: ratingCount, |
|
}, { |
|
tags: ['website'], |
|
feature: 'dashboard', |
|
stage: 'new user', |
|
data: {} |
|
} |
|
); |
|
} |
|
(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="https://cdn.branch.io/branch-v1.8.4.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 banner closeBanner creditHistory credits data deepview deepviewCta first getCode init link logout redeem referrals removeListener sendSMS setIdentity track validateCode".split(" "), 0); |
|
function sendSMS(form) { |
|
var phone = form.phone.value; |
|
var linkData = { |
|
tags: [], |
|
channel: 'Website', |
|
feature: 'TextMeTheApp', |
|
data: { |
|
"event": "<?php $id ?>" |
|
} |
|
}; |
|
var options = {}; |
|
var callback = function(err, result) { |
|
if (err) { |
|
alert("Sorry, something went wrong."); |
|
} |
|
else { |
|
alert("SMS sent!"); |
|
} |
|
}; |
|
branch.sendSMS(phone, linkData, options, callback); |
|
form.phone.value = ""; |
|
}; |
|
|
|
var readyStateCheckInterval = setInterval(function() { |
|
if (document.readyState === "complete") { |
|
var script = document.createElement('script'); |
|
script.src = "https://itunes.apple.com/lookup?id="+appID+"&callback=getRating"; |
|
document.body.appendChild(script); |
|
clearInterval(readyStateCheckInterval); |
|
} |
|
}, 3); |
|
</script> |
|
</head> |
|
<body> |
|
<h2>Be sure to set the AppStore ID and the Branch API Key</h2> |
|
</body> |
|
</html> |