Skip to content

Instantly share code, notes, and snippets.

@slorber
Created December 22, 2015 11:38
Show Gist options
  • Save slorber/e6c891f0ef8adaded84a to your computer and use it in GitHub Desktop.
Save slorber/e6c891f0ef8adaded84a to your computer and use it in GitHub Desktop.
if ( typeof cordova !== "undefined" ) {
// See https://github.com/EddyVerbruggen/Custom-URL-scheme
window.handleOpenURL = function handleOpenURL(url) {
setTimeout(function() { // setTimeout is required see plugin doc!
if ( url && (url.indexOf("stample://mobileclipper?") == 0) ) {
var queryString = parseQueryString(url);
if ( isClippableUrl(queryString.url) ) {
publishUrl(queryString.url, queryString.title);
}
else {
alert("not supported clipper url queryString: " + JSON.stringify(queryString));
}
}
else {
alert("not supported url: " + url);
}
}, 0);
};
// ANDROID
cordova.SharingReceptor.listen(function(data) {
var subject = data.intent.extras["android.intent.extra.SUBJECT"];
var text = data.intent.extras["android.intent.extra.TEXT"];
var fileUri = data.intent.extras["android.intent.extra.STREAM"];
if ( isClippableUrl(text) ) {
publishUrl(text, subject);
}
else {
alert("not supported android clipping: " + JSON.stringify(data));
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment