How to integrate whatsapp into ios

hi now i am trying to integrate which application into our application

I have already done the integration Tweet

: - in this application I create two buttons, one button (selectImagePressed) selects the local image form file, and then the second (tweetButtonPressed), this is the image message in tweeter

- (IBAction)tweetButtonPressed:(id)sender { if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) { SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; [tweetSheet setInitialText:@"Look at this nice picture!"]; [tweetSheet addImage:self.imageView.image]; [self presentViewController:tweetSheet animated:YES completion:nil]; } else { UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:@"please setup Twitter" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alertView show]; } } - (IBAction)chooseImagePressed:(id)sender { self.pickerController = [[UIImagePickerController alloc] init]; self.pickerController.delegate = self; self.pickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; [self presentViewController:self.pickerController animated:YES completion:nil]; } #pragma mark - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info; { self.imageView.image = [info objectForKey:UIImagePickerControllerOriginalImage]; [self dismissViewControllerAnimated:YES completion:nil]; } 

Please give me an idea of ​​how to integrate the application into our application.

Please tell me whether this is possible or not.

thanks

0
source share
4 answers

No , this is not possible as like tweeter and Facebook api . But you can send a message from your application to whatsapp if whatsapp is already installed below

 NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?text=Hello%2C%20World!"];//use this method stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding to convert it with escape char if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) { [[UIApplication sharedApplication] openURL: whatsappURL]; } 

But if you want to share documents such as files, images, videos, you have to send it through the UIDocumentInteractionController.

Note. whatsapp should be installed above two, otherwise you will not be able to do anything as you like. See this for the current whatsApp document.

+4
source

Easy integration

  NSURL *whatsappURL = [NSURL URLWithString:@"https://api.whatsapp.com/send?phone=9530670491&text=hello"]; if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) { [[UIApplication sharedApplication] openURL: whatsappURL]; } 

Swift

 var whatsappURL = URL(string: "https://api.whatsapp.com/send?phone=9530670491&text=hello") if UIApplication.shared.canOpenURL(whatsappURL) { UIApplication.shared.openURL(whatsappURL!) } 

Also check out this link https://www.whatsapp.com/faq/en/general/26000030

+2
source

Here you will get more input:

http://www.whatsapp.com/faq/en/iphone/23559013

-This is used to share any images / vodeo with WhatsApp. -You must make a reference to the UIDocumentInteractionController Class in your code. -You must save the image to disk, and then create a UIDocumentInteractionController with this file URL. -Note - these are code bindings for the same thing, and you can exchange them with WhatsApp.

  //Path of the image which is present in bundle NSString* path = [[NSBundle mainBundle] pathForResource:@"images" ofType:@"jpg"]; /* here you can also give the path of image which is saved on disk.*/ if (path) { NSURL* url = [NSURL fileURLWithPath:path]; UIDocumentInteractionController* docController = [UIDocumentInteractionController interactionControllerWithURL:url]; docController.delegate = self; [docController presentPreviewAnimated:YES]; } 

For text messaging

  //This is sharing text encoding with NSUTF8StringEncoding NSString* strSharingText = [txtWhatsApp.text stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; //This is whatsApp url working only when you having app in your Apple device NSURL *whatsappURL = [NSURL URLWithString:[NSString stringWithFormat:@"whatsapp://send?text=%@",strSharingText]]; if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) { [[UIApplication sharedApplication] openURL: whatsappURL]; } 
+1
source

For Swift 4.2 and higher

 let whatsAppURL = URL(string: "https://api.whatsapp.com/send?phone=0123456") if UIApplication.shared.canOpenURL(whatsAppURL!) { UIApplication.shared.open(whatsAppURL!, options: [:], completionHandler: nil) } 
0
source

All Articles