Preparazione dell'app per aggiungere il bottone per fare lo sharing

This commit is contained in:
gine 2017-03-18 12:43:16 +01:00
parent 0324931898
commit 2cabd00de7
2 changed files with 22 additions and 1 deletions

View file

@ -43,6 +43,7 @@
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/push.js"></script>
<script type="text/javascript" src="js/share.js"></script>
<script type="text/javascript">
$(document).on("mobileinit", function () {
@ -158,7 +159,7 @@
</div>
<!-- /header -->
<!-- Home page -->
<div data-role="page" id="index" data-dom-cache="true" data-theme="a" class="ui-page">
<center><p><img src="image/xm-logo.png" class="rwd" /></p>
<ul data-role="listview" data-inset="true">
@ -334,6 +335,7 @@
<script>
//funzione carica pagina
</script>
<button onclick="window.plugins.socialsharing.share('Message only')">message only</button>
</div>
<!-- chiude body-->
</div>

19
www/js/share.js Normal file
View file

@ -0,0 +1,19 @@
// this is the complete list of currently supported params you can pass to the plugin (all optional)
var options = {
message: 'share this', // not supported on some apps (Facebook, Instagram)
subject: 'the subject', // fi. for email
files: ['', ''], // an array of filenames either locally or remotely
url: 'https://www.website.com/foo/#bar?a=b',
chooserTitle: 'Pick an app' // Android only, you can override the default share sheet title
}
var onSuccess = function(result) {
console.log("Share completed? " + result.completed); // On Android apps mostly return false even while it's true
console.log("Shared to app: " + result.app); // On Android result.app is currently empty. On iOS it's empty when sharing is cancelled (result.completed=false)
}
var onError = function(msg) {
console.log("Sharing failed with message: " + msg);
}
window.plugins.socialsharing.shareWithOptions(options, onSuccess, onError);