I’ve implemented in my app buttons to share a comment via facebook, twitter, whatsapp, etc…
Whatsapp and twitter works great but if i call to methods facebook o shareapp(googleplus.app.com ) the plugin doesn’t works and throws an error if i do a promise.
Maybe this can be happening because i dont have facebook on my device?
Anyone can share some code who works? Thanks
Sujan12
August 29, 2017, 11:57pm
#2
Share your exact error and ionic info
output please.
googlePlus(){
this.socialSharing.shareVia('plus.google.com', '¡Hi!',
'Imsharingthis.', null, this.shareurl)
.then(() => {
console.log('It works');
}).catch(()=>{
setTimeout(()=>{
this.errorShare();
}, 1500);
});
}
whatsapp(){
this.socialSharing.shareViaWhatsApp('¡Hi!', null, this.shareurl)
.then(() => {
console.log('It works');
}).catch(()=>{
setTimeout(()=>{
this.errorShare();
}, 1500);
});
}
facebook(){
// this.socialSharing.shareViaFacebook('Hil', null, this.shareurl);
this.socialSharing.shareViaFacebookWithPasteMessageHint('Hi!', null, this.shareurl, ' La red social provincial')
.then(() => {
console.log('It works');
}).catch(()=>{
setTimeout(()=>{
this.errorShare();
}, 1500);
});
}
twitter(){
this.socialSharing.shareViaTwitter('¡HI!, null, this.shareurl)
.then(() => {
console.log('It works');
}).catch(()=>{
setTimeout(()=>{
this.errorShare();
}, 1500);
});
}
Google+ and facebook methods doesn’t works
Hi, @temohpab
Could you try with shareWithOptions
$ ionic plugin add cordova-plugin-x-socialsharing
component file :
import { SocialSharing } from 'ionic-native';
shareRecipe() {
SocialSharing.shareWithOptions({
message: `${this.title} - ${this.description}: ${this.recipeUrl}`
}).then(() => {
console.log('Shared!');
}).catch((err) => {
console.log('Oops, something went wrong:', err);
});
}
View file :
<button ion-button (click)="shareRecipe()">
<ion-icon name="share"></ion-icon>
</button>
Hope this will solve your Issue.
Thanks
This could be a solution but i want to share in that specific pages
This is my info
@ionic/cli-utils : 1.9.2
ionic (Ionic CLI) : 3.9.2
global packages:
Cordova CLI : 7.0.1
local packages:
@ionic/app-scripts : 2.0.2
Cordova Platforms : android 6.2.3
Ionic Framework : ionic-angular 3.5.3
System:
Node : v6.11.2
npm : 3.10.10
OS : Windows 10
Now facebook it’s working, now only fails with Google+