I am trying to share a YouTube link in Whats App with :
NSURL *whatsappURL = [NSURL URLWithString:@"whatsapp://send?text=http://www.youtube.com/watch?v=lWA2pjMjpBs"];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];
}
But when Whats App opens the message box is empty. Any idea why this happens?
I found the answer if someone have the same problem:
You just need to encode the url:
NSString *str = [NSString stringWithFormat:youTubeLink,videoId];
str = (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,
(CFStringRef)str,
NULL,
CFSTR("!*'();:@&=+$,/?%#[]"),
kCFStringEncodingUTF8);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With