EddyVerbruggen / SocialSharing-PhoneGap-Plugin

👨‍❤️‍💋‍👨 Cordova plugin to share text, a file (image/PDF/..), or a URL (or all three) via the native sharing widget
MIT License
1.78k stars 908 forks source link

Sharing error for Ionic5 #1157

Open lsantaniello opened 3 years ago

lsantaniello commented 3 years ago

Hi, I need to integrate Whatzapp sharing on my ionic 5 app.

I built android app but when I share on whatzapp, I receive a strange error on a specific device. On others devices, it works.

Whatzapp sharing error

(5) ['com.android.bluetooth', 'com.google.android.gms', 'com.mi.android.globalFileexplorer', 'com.miui.notes', 'com.xiaomi.midrop']
0: "com.android.bluetooth"
1: "com.google.android.gms"
2: "com.mi.android.globalFileexplorer"
3: "com.miui.notes"
4: "com.xiaomi.midrop"
length: 5
[[Prototype]]: Array(0)

This is my simple code:

  var message, image, url: string;

    message = "hello";
    url = "http://www.mylink.com";

    if (this.session.getPlatform() == "ios") {
      this.socialSharing.shareViaWhatsApp(message, null, url).then(() => {
        console.debug("Whatzapp sharing success");
      }).catch((e) => {
        console.error("Whatzapp sharing error", e);
      });
    } else {
      this.socialSharing.shareViaWhatsApp(message, image, url).then(() => {
        console.debug("Whatzapp sharing success");
      }).catch((e) => {
        console.error("Whatzapp sharing error", e);
      });
    }

Can you help me to understand?

Thanks

erixschueler commented 3 years ago

I also got this error. The reason is that Android targeting API Level 30 needs permission for sharing.

Solution is here: https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin/issues/1150#issue-959050458

Hope it helps.