Reputation: 16132
I'm using the UIDocumentInteractionController method to share images from my app to WhatsApp (explained in How send image to WhatsApp from my application?, WhatsApp image sharing iOS).
I'm also aware of the share via URI option, used to share texts only (explained here: https://www.whatsapp.com/faq/iphone/23559013).
Is there a way to share both an image and a caption in a single share?
Upvotes: 18
Views: 11047
Reputation: 779
You can share an image + text on whatsapp IFF you share a link along
For both options you will need to store the image somewhere online as the workaround is based on whatsapp's link preview feature
For example can upload the image to a s3 bucket or firebase storage.
Option 1: You can control the shared link response
Using Open Graph tags:
<meta property="og:image" content="http://yourimage_with_complete_URL.png"/>
<meta property="og:title" content="Your Title"/>
<meta property="og:description" content="Your description."/>
Option 2: You can't control the shared link response
Using firebase dynamic links (or similar service)
Then simply set the image's URL to the socialMetaTagParameters
of the Firebase DynamicLinkComponents
:
linkBuilder.socialMetaTagParameters = DynamicLinkSocialMetaTagParameters()
linkBuilder.socialMetaTagParameters.title = "Example of a Dynamic Link Title"
linkBuilder.socialMetaTagParameters.descriptionText = "Example of a Dynamic Link descriptionText"
linkBuilder.socialMetaTagParameters.imageURL = "https://www.example.com/my-image.jpg"
Now pass the the created firebase dynamic link to the UIActivityController
along with the text you want to share as you usually do. This will display the image in whatsapp using whatsapp's link preview feature along side the passed text.
Check the firebase documentation for more info.
Upvotes: 0
Reputation: 2689
Currently there is no way that you can share both image and text together on whatsapp. Sharing both image and text together is not handled from the whatsapp side.
So, at a time you can share only image or text.
Upvotes: 2
Reputation: 140
You can use the UIDocumentInteractionController as mentioned in the 2nd answer to this question as of August 4, 2014: Share image/text through WhatsApp in an iOS app
Upvotes: 0
Reputation: 29
from my experience and knowledge "UIDocumentInteractionController" is the only way of doing it for now...
Upvotes: 0