Hello till now i can share my content on whatsapp using javascript code but still not able to share image with text. Does anyone done it? Here is my javascript code:
$(document).ready(function() {
$(document).on("click", '.mct_whatsapp_btn', function() {
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
var text = $(this).attr("data-text");
var url = $(this).attr("data-link");
var message = encodeURIComponent(text) + " - " + encodeURIComponent(url);
var whatsapp_url = "whatsapp://send?text=" + message;
window.location.href = whatsapp_url;
} else {
alert("Please use an Mobile Device to Share this Article");
}
});
});
js) → We need to scan this QR from the WhatsAPPWeb from WhatsApp mobile app. var data = [{ id: 1, received: 'Hello', reply: 'Hi'},{ id: 2, received: 'Sorry', reply: 'No problem'},{ id: 3, received: 'Can we have a call? ', reply: 'Please leave a voicemail.
Use https://wa.me/<number> where the <number> is a full phone number in international format. Omit any brackets, dashes, plus signs, and leading zeros when adding the phone number in international format. Universal links can also include a pre-filled message that will automatically appear in the text field of a chat.
If you have a website and want to open a WhatsApp chat with a pre-filled message, you can use our custom URL scheme to do so. Opening whatsapp://send?text= followed by the text to send, will open WhatsApp, allow the user to choose a contact, and pre-fill the input field with the specified text.
To configure automatic photo, video or audio downloading, simply go to WhatsApp > tap More options > Settings > Storage and data > Media auto-download. Here you can choose when WhatsApp will automatically download media.
If you are trying to do this from browser then as per whatsapp docs, you can only send text or link through this. read it here : https://www.whatsapp.com/faq/en/iphone/23559013
If you want to send image with this whatsapp protocol, you can first upload image to your server and then use 'encodeURIComponent' to send link with this:
'whatsapp://send?text='+encodeURIComponent(imageURL)
As already pointed by @Akis, for using it in hybrid app framework like cordova/ionic, its better if you search for plugin to achieve this.
https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin
Above link with cordova plugin might help you in that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With