如何在iOS中集成whatsapp

嗨,现在我正在尝试在我们的应用程序集成什么是应用程序

我已经完成了整合Tweet

: – 在这个应用程序中,我创build两个button之一(chooseImagePressed)button是select图像forms本地文件,然后再次(tweetButtonPressed)这是张贴图像到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]; } 

请给我任何关于如何将应用程序集成到我们的应用程序的想法

请告诉我这是可能的或不可以

谢谢

,这不可能as like tweeter and Facebook api 。 但是你可以发送消息从你的应用程序到WhatsApp如果WhatsApp已经安装如下

 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]; } 

但是如果你想共享像文件,图像,video文件,你必须通过UIDocumentInteractionController发送。

注意: whatsapp应该安装上面两个,否则你不能做任何事情,只要你喜欢。 看到这个当前whatsApp文档。

你会在这里得到更多的input:

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

– 这是用来分享任何与WhatsApp的图像/dynamic。 – 你需要在你的代码中做UIDocumentInteractionController类引用。 – 您需要将图像保存到磁盘,然后使用该文件URL创build一个UIDocumentInteractionController。 – 以下是代码捕捉相同的,你可以与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]; } 

用于文字分享

  //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]; } 

简单的集成

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

迅速

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

另外检查这个链接https://www.whatsapp.com/faq/en/general/26000030