使用Ionic 2 SocialSharing插件进行Firebase存储

时间:2016-12-07 14:50:12

标签: firebase ionic-framework ionic2 cordova-plugins firebase-storage

我的图片存储在firebase存储中。我注意到如果我将图像存储在一个文件夹中,我就无法再使用离子原生的SocialSharing plugin

有人找到了解决方法吗?

whatsappShare() {

        let image = "https://firebasestorage.googleapis.com/v0/b/instagram-test-fe4a8.appspot.com/o/000.jpg?alt=media&token=64dd92cd-27c2-4c36-9c1d-2ab376ffd16c"  //This is working
        //let image = "https://firebasestorage.googleapis.com/v0/b/instagram-test-fe4a8.appspot.com/o/test%2F000.jpg?alt=media&token=2bc49648-cf1c-41fe-8e1f-071d54f56402"  //This is failing because stored in test/ folder

        //shareViaWhatsApp(message, image, url) 
        SocialSharing.shareViaWhatsApp("Checkout this picture!", image, "lycos.com/")
            .then( () => {
                    alert("WhatsApp Success");
                }, () => {
                    alert("WhatsApp failed")
                })
    }

我发现这个github看起来很相关 https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin/issues/696

这意味着该插件可以在iOS中运行并在android中失败? 任何可能的解决方案?

1 个答案:

答案 0 :(得分:1)

是。最后,我得到了一种方法,可以将Firebase存储中的图像共享到任何服务。请遵循以下两个条件:

  1. 将图像从uri转换为base64字符串。你可以在那里找到很多转换的例子。
  2. 使用shareWithOptions()发送图像数据。其他方法似乎不适用于以这种方式编码的图像数据。
  3. 我对此问题的任何其他更新感兴趣。希望能帮助任何人。