我听说过URL方案,但在Whatsapp打开后我无法返回我的应用程序。
我引用了此链接http://www.whatsapp.com/faq/en/iphone/23559013
以下是我复制到我的应用中的代码段:
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 installed." message:@"Your device has WhatsApp installed." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}