如何从我的ios应用程序打开VK应用程序

时间:2014-08-08 14:09:41

标签: ios vk

我想在vk app中打开我的公共页面(如果已安装)。我怎样才能做到这一点

这是与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"]];
    }
}

感谢名单!

3 个答案:

答案 0 :(得分:8)

嗨,它可以帮助你:)

NSURL *url = [[NSURL alloc] initWithString:@"vk://vk.com/ХХХ"];
[[UIApplication sharedApplication] openURL:url];

答案 1 :(得分:7)

这适用于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)
}

答案 2 :(得分:0)

let appURL = NSURL(string: "vk://vk.com/id1")!
let safariURL = NSURL(string: "vk.com/id1")!

if UIApplication.sharedApplication().openURL(appURL){
    UIApplication.sharedApplication().openURL(safariURL))
}