简体   繁体   中英

How to share long text content in Whatsapp using Ionic

I have strange problem with WhatsApp sharing. When I am sharing it doesn't share full text. Text is arround 1000 lines but not share all lines!! What is the problem? Is there any limit to text? I am using this plugin : https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin

sharedata() {
    let msgToShare = '*Data1*' + '\r\n' + this.maindata.d1+ '\r\n' + this.maindata.d2+ '\r\n\n' + '*Data2*' + this.maindata.d3+ '\r\n\n' + '*Data3*' + this.maindata.d4+ '\r\n\n' + '*Data4' + this.maindata.d5+ '\r\n\n' + '*Data5*' + this.maindata.d6;
    console.log(msgToShare);
    var options = {
        message: msgToShare
    }

    var onSuccess = function (result) {
        console.log("Share completed? " + result.completed); // On Android apps mostly return false even while it's true
        console.log("Shared to app: " + result.app); // On Android result.app is currently empty. On iOS it's empty when sharing is cancelled (result.completed=false)
    }

    var onError = function (msg) {
        console.log("Sharing failed with message: " + msg);
    }
    window['plugins'].socialsharing.shareWithOptions(options, onSuccess, onError);
}

Whatsapp has limit of number of characters in a single message and it's 65536 that is 2^16. So make your mathematics to calculate text length.


  1. To be sure that its not plugin/your code problem, share long text via mail. If everything is ok, therefore its Whatsapp restrictions and you have nothing to do with that but split long text to chunks and send several messages
  2. Copy long text manually and paste in Whatsapp, I believe you will get the same behavior

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM