Last active
December 12, 2015 00:38
-
-
Save brycehamrick/4685091 to your computer and use it in GitHub Desktop.
Pass the Backplane channel ID to the server via JSONP
This file contains 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
(function() { | |
if (typeof window.Backplane !== 'function' || parseInt(Backplane.version) !== 2) | |
return; | |
/** | |
* Callback function to be executed on BP ready | |
*/ | |
function bp_ready_callback() { | |
// Get the channel ID | |
var bpChannel = Backplane.getChannelID(); | |
// Pass via JSONP to an endpoint "url" | |
var script = document.createElement('script'); | |
script.type = "text/javascript"; | |
script.src = url | |
+ "&bp_channel=" + encodeURIComponent(bpChannel); | |
document.getElementsByTagName('HEAD')[0].appendChild(script); | |
} | |
// Pass in function from above | |
Backplane(bp_ready_callback); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment