如何从iOS7中的whatsapp回到我的应用程序

时间:2014-07-15 09:17:17

标签: ios7 whatsapp

我听说过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];
}

0 个答案:

没有答案