For encoding use below.
NSString *str = [NSString stringWithFormat:@"http://www.youtube.com/watch?v=lWA2pjMjpBs" ]; str = [str stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSURL *whatsappURL = [NSURL URLWithString:[NSString stringWithFormat:@"whatsapp://send?text=%@", str]]; if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) { [[UIApplication sharedApplication] openURL: whatsappURL]; }
His work ... verified ...
Note
You cannot send whatsapp to a specific number. This is the flaw that we have.
To send whatsapp messages to a specific number, this can be done below.
NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?abid=1&text=Hello"]; ^^^^
Try this code.
abid means the address book identifier. Now, whatever your iPhone number is with id = 1, it will select that number.
The problem with abid is that abid for this number is NOT ONLY on all iPhone. The funds in your iPhone abid = 1 - 12345, but in my iPhone abid = 1 - 34567.
Also, if this number is not saved on the iPhone, you cannot send the whatsapp link to this number directly from the iOS application.
Fahim parkar
source share