[英]Ionic 2 social share
I want to "share user stats" in my Ionic 2 app. 我想在Ionic 2应用程序中“共享用户统计信息”。 First, I do a screenshot, and then I want to share it with social share plugin.. 首先,我做一个截图,然后我想与社交共享插件共享它。
This is my code: 这是我的代码:
public shareStats(): void {
// Take a screenshot and get temporary file URI
Screenshot.URI(100)
.then((img) => {
this.platform.ready().then(() => {
let message: string = 'Message';
let subject: string = 'Stats';
let file = img;
let link = 'https://www.example.com';
SocialSharing.share(message, subject, file, link);
});
}, (err) => {
let prompt = this.alertCtrl.create({
title: 'Fallo',
subTitle: err,
buttons: ['Aceptar']
});
prompt.present();
console.log(err);
});
}
Well, Screenshot plugin appears to work fine, but i don't know what is happening after I added the social share code into it. 好了,Screenshot插件似乎可以正常工作,但是在添加社交共享代码后我不知道发生了什么。 Because my device do not open the tipically share options window. 因为我的设备没有打开“通常共享选项”窗口。
In short, I need to do screenshot and share it on social networks. 简而言之,我需要做截图并在社交网络上分享。 But I do not know what I'm doing wrong because I can not debug it by being a cordova plugin and running only on mobile devices. 但是我不知道自己在做什么错,因为我无法通过成为cordova插件并仅在移动设备上运行来对其进行调试。
It makes me a bit of noise what I'm sending as a parameter: let file = img;
我作为参数发送的内容使我有些不明白: let file = img;
Because I do not know what it contains or what kind of data this img is that returns me Screenshot.URI
, because I can not debug it with the mobile device. 因为我不知道它包含什么内容或该img返回了什么样的数据,所以我无法通过移动设备调试它返回我Screenshot.URI
。
Thank's so much in advance! 太感谢了!
Ivan. 伊万
I solved it: 我解决了:
public shareStats(): void {
this.platform.ready().then(() => {
// Take a screenshot and get temporary file URI
Screenshot.URI(100)
.then((res) => {
var options = {
message: this.SHARE_OPTIONS_MESSAGE,
subject: '', // fi. for email
files: [res.URI], // an array of filenames either locally or remotely
url: this.SHARE_OPTIONS_URL,
chooserTitle: this.SHARE_OPTIONS_CHOOSER_TITLE // Android only
}
SocialSharing.shareWithOptions(options)
.then(() => {
this.showSuccessShareMsg();
})
.catch((err) => {
this.showErrorShareMsg(err);
});
}, (err) => {
});
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.