Humble Chicken
Humble Chicken

Reputation: 19

Ionic 6 Angular Social Sharing Using Capacitor-Filesharer

recently I'm just realized that my mobile application isn't working on Android API 33 and above (Android 14). I figured that on Android API 32 and above, the storage permission is automatically granted if i'm not mistaken. Turns out I have no idea how can I overcome this issue.

Library used : @byteowls/capacitor-filesharer v4.

This is what I have been doing. It works pretty well in Android API 32 and below.

async shareCert(ct_id = ""){
    var formData = new FormData();
    formData.append("cert_id", ct_id);

    const loader = await this.loadingCtrl.create({
      message : "Generating Certificate ..."
    });
    loader.present();

    this.accessProviders.postData(formData, "app/certificates/export_certificate").subscribe((response : any) => {
      console.log(response);

      if (response.valid == true){
        console.log("export start");
        loader.dismiss();
        FileSharer.share({
          filename: response.filename,
          contentType: response.contentType,
          base64Data : response.base64Data
        }).then(() => {
          console.log("jadi");

        }).catch (error => {
          console.error("File sharing failed", error);
        })
      }
      else{
        loader.dismiss();
        this.presentAlert("Unable to Share Certificates");
      }
    })
  }```

Upvotes: 0

Views: 78

Answers (0)

Related Questions