1

I tried using this method for sending message on whatsapp from my iOS app.

For text

NSString * msg = @"YOUR MSG";

NSString * urlWhats = [NSString stringWithFormat:@"whatsapp://send?text=%@",msg];

NSURL * whatsappURL = [NSURL URLWithString:[urlWhats stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];

}
 else {
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"WhatsApp not installed." message:@"Your device has no WhatsApp installed." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];

  [alert show];
}

I have 2 questions.

1.) how to get back to the app from Whatsapp.

2.) How to send message or image etc by entering phone number instead of fetching from contacts list.

ZeMoon
  • 20,054
  • 5
  • 57
  • 98
simardeep singh
  • 220
  • 2
  • 11

0 Answers0