You can use this code to accomplish what you want:
NSString *phoneNumber = @"1112223333"; NSString * const viberScheme = @"viber://"; NSString * const tel = @"tel"; NSString * const chat = @"chat"; NSString *action = @"<user selection, chat or tel>"; // this could be @"chat" or @"tel" depending on the choice of the user if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:viberScheme]]) { // viber is installed NSString *myString; if ([action isEqualToString:tel]) { myString = [NSString stringWithFormat:@"%@:%@", tel, phoneNumber]; } else if ([action isEqualToString:chat]) { myString = [NSString stringWithFormat:@"%@:%@", chat, phoneNumber]; } NSURL *myUrl = [NSURL URLWithString:[viberScheme stringByAppendingString:myString]]; if ([[UIApplication sharedApplication] canOpenURL:myUrl]) { [[UIApplication sharedApplication] openURL:myUrl]; } else { // wrong parameters } } else { // viber is not installed }
Juan catalan
source share