In my app I need to send links via WhatsApp. So this is how I do that:
NSString* link = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL,
(CFStringRef)resource.shareURL.absoluteString,
NULL,
CFSTR("!*'();:@&=+$,/?%#[]"),
kCFStringEncodingUTF8));
NSString * urlWhats = [NSString stringWithFormat:@"whatsapp://send?text=%@", link];
NSURL * whatsappURL = [NSURL URLWithString:urlWhats];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL]) {
[[UIApplication sharedApplication] openURL: whatsappURL];
} else {
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Unknown error"
message:@"Can't open Whatsapp"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
But the problem is that it doesn't return automatically to my app after the message is sent. User needs to get back to the app manually. So how do I make it return to my app? Is it even possible?