0

I want to integrate WhatsApp sharing in my app but I don't want to use UIDocumentInteractionController. Is there any way to share image using url scheme ? like we share text using url scheme using following code below

var whatsappURL:NSURL?= NSURL(string: "whatsapp://send?text=Hello%2C%20World!")
if (UIApplication.shared.canOpenURL(whatsappURL)) {    
        UIApplication.shared.openURL(whatsappURL) 
    }
Dimple
  • 788
  • 1
  • 11
  • 27

1 Answers1

0

I think you can't do it.

Firstly, the Whatapps only support send text via URLScheme. Secondly, how you can put your image in the urlString? Convert it to base64string?

You can only send image by using UIDocumentInteractionController

Quoc Nguyen
  • 2,839
  • 6
  • 23
  • 28
  • actually i did same thing with instagram and i shared image using url scheme here is my code for instagram (i am posting code in next comment because of character limit) – Vishal Malvi Sep 19 '18 at 06:22
  • ` let instagramURL = NSURL(string: "instagram://app") PHPhotoLibrary.shared().performChangesAndWait { let request = PHAssetChangeRequest.creationRequestForAsset(from: self.image) let assetID = request.placeholderForCreatedAsset?.localIdentifier ?? "" let shareURL = "instagram://library?LocalIdentifier=" + assetID if UIApplication.shared.canOpenURL(instagramURL! as URL) { if let urlForRedirect = NSURL(string: shareURL) { UIApplication.shared.openURL(urlForRedirect as URL) } ` – Vishal Malvi Sep 19 '18 at 06:26