我想在我的Ionic 2应用程序中“分享用户数据”。首先,我做了一个截图,然后我想把它分享给社交分享插件。
这是我的代码:
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);
});
}
Screenshot插件似乎工作得很好,但我不知道在我添加了社交分享代码后会发生什么。因为我的设备没有打开tipically options窗口。
简而言之,我需要截图并在社交网络上分享。但我不知道我做错了什么,因为我不能通过作为cordova插件来调试它,并且只能在移动设备上运行。
我发送的参数是:let file = img;
,因为我不知道它包含什么,也不知道这个img返回给我的Screenshot.URI
是什么类型的数据,因为我不能用移动设备调试它。
提前感谢了这么多!
伊万。
发布于 2017-02-28 05:26:59
我解决了这个问题:
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) => {
});
});
}
https://stackoverflow.com/questions/42493968
复制相似问题