2017-02-27 6 views
0

私のIonic 2アプリで「ユーザー統計情報を共有したい」とします。まず、私はスクリーンショットを行い、その後、私は、ソーシャルシェアプラグインとそれを共有したい...Ionic 2 social share

これは私のコードです:

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); 
      }); 
    } 

まあ、スクリーンショットプラグインが正常に動作するように見えるが、私はそうではありませんソーシャルシェアコードを追加した後に何が起きているかを知る私のデバイスはtipically共有オプションのウィンドウを開きませんので。

要するに、スクリーンショットをしてソーシャルネットワーク上で共有する必要があります。しかし、私は間違って何をしているのかわかりません。なぜなら、私はコード・プラグインであり、モバイル・デバイス上でしか実行できないため、デバッグできないからです。それは私に私がパラメータとして送信しています何のノイズのビットを作る

let file = img; 私はそれが含まれているか、私はそれをデバッグすることはできませんので、データの種類このIMGが、私にScreenshot.URI返すことが何であるかを知らないのでモバイルデバイス。

ありがとうございます!

Ivan。

答えて

0

私はそれを解決:

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) => { 

       }); 
     }); 

    }