objective c - Share an Image and Text on WhatsApp in IOS programmatically? -
i add image , text in whatsapp of coding. how can perform solve problem?
you can post image or text on whatsapp. wont post both @ time becouse whatsapp not provide api can add caption , post image text.
following example posting image iphone app whatsapp par whatsapp documentation:
in viewcontroller.h file:
@interface viewcontroller : uiviewcontroller { } @property(nonatomic,retain) uidocumentinteractioncontroller *documentationinteractioncontroller;
in viewcontroller.m file:
- (ibaction)bocclick:(uibutton *)sender { nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdirectory = [paths objectatindex:0]; nsstring *getimagepath = [documentsdirectory stringbyappendingpathcomponent:@"savedimage.png"]; //here fetched image path document directory , convert in url , use bellow nsurl *imagefileurl =[nsurl fileurlwithpath:getimagepath]; nslog(@"imag %@",imagefileurl); self.documentationinteractioncontroller.delegate = self; self.documentationinteractioncontroller.uti = @"net.whatsapp.image"; self.documentationinteractioncontroller = [self setupcontrollerwithurl:imagefileurl usingdelegate:self]; [self.documentationinteractioncontroller presentopeninmenufromrect:cgrectzero inview:self.view animated:yes]; } - (uidocumentinteractioncontroller *) setupcontrollerwithurl: (nsurl*) fileurl usingdelegate: (id ) interactiondelegate { self.documentationinteractioncontroller = [uidocumentinteractioncontroller interactioncontrollerwithurl: fileurl]; self.documentationinteractioncontroller.delegate = interactiondelegate; return self.documentationinteractioncontroller; }
Comments
Post a Comment