I want to open my public page in vk app (if it is installed). How can I manage to do that
Here's the same trick with facebook
- (IBAction)facebook:(id)sender{
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fb://profile/1425897281000202"]]){
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"fb://profile/1425897281000202"]];
NSURL *url = [NSURL URLWithString:@"fb://profile/1425897281000202"];
[[UIApplication sharedApplication] openURL:url];
}
else {
[[UIApplication sharedApplication]
openURL:[NSURL URLWithString:@"https://www.facebook.com/GooodApps"]];
}
}
Thanx!
Hi it should help you :)
NSURL *url = [[NSURL alloc] initWithString:@"vk://vk.com/ХХХ"];
[[UIApplication sharedApplication] openURL:url];
This works for me in Swift:
let appURL = NSURL(string: "vk://vk.com/id\(user.vkID)")!
let safariURL = NSURL(string: "vk.com/id\(user.vkID)")!
if UIApplication.sharedApplication().canOpenURL(appURL){
UIApplication.sharedApplication().openURL(appURL)
} else {
UIApplication.sharedApplication().openURL(safariURL)
}
let appURL = NSURL(string: "vk://vk.com/id1")!
let safariURL = NSURL(string: "vk.com/id1")!
if UIApplication.sharedApplication().openURL(appURL){
UIApplication.sharedApplication().openURL(safariURL))
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.