How to open VK app from my ios app
Asked Answered
S

3

5

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!

Spurry answered 8/8, 2014 at 14:9 Comment(0)
G
9

Hi it should help you :)

NSURL *url = [[NSURL alloc] initWithString:@"vk://vk.com/ХХХ"];
[[UIApplication sharedApplication] openURL:url];
Gittern answered 8/10, 2014 at 17:11 Comment(8)
Do you know perhaps of a similar solution for the Android app ?Phylactery
I can be wrong, but this URL schema should also work for android.Gittern
I tried. It didn't, even though the other social networks apps URIs are identical . :( I've made a post about it here: https://mcmap.net/q/1921227/-how-to-open-vkontakte-app-with-a-specific-friend/878126Phylactery
Hmm... strange, Ok I can ask how my android friends implemented this, on the next week.Gittern
I wonder where they've found it. I don't speak Russian, and it's quite hard for me to search there for this information. Thank you.Phylactery
I speak Russian, but it was difficult to find this URL schema even for me :D Sure, no problem)Gittern
Hi again, my android friend told me that he has exception using this URL schema, maybe android VK application doesn't support it(( but he give me this link github.com/VKCOM/vk-android-sdk, maybe it will help you.Gittern
They answered me, so I told them to put the answer on SO, so that I could thank them. Anyway, thank you for your help !Phylactery
F
10

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)
}
Flanna answered 7/2, 2015 at 11:36 Comment(2)
For groups use "vk://vk.com/clubXXXXXX" where XXXXXX=id.Gwalior
let safariURL = NSURL(string: "vk.com/id(user.vkID)")! That works better)Spurry
G
9

Hi it should help you :)

NSURL *url = [[NSURL alloc] initWithString:@"vk://vk.com/ХХХ"];
[[UIApplication sharedApplication] openURL:url];
Gittern answered 8/10, 2014 at 17:11 Comment(8)
Do you know perhaps of a similar solution for the Android app ?Phylactery
I can be wrong, but this URL schema should also work for android.Gittern
I tried. It didn't, even though the other social networks apps URIs are identical . :( I've made a post about it here: https://mcmap.net/q/1921227/-how-to-open-vkontakte-app-with-a-specific-friend/878126Phylactery
Hmm... strange, Ok I can ask how my android friends implemented this, on the next week.Gittern
I wonder where they've found it. I don't speak Russian, and it's quite hard for me to search there for this information. Thank you.Phylactery
I speak Russian, but it was difficult to find this URL schema even for me :D Sure, no problem)Gittern
Hi again, my android friend told me that he has exception using this URL schema, maybe android VK application doesn't support it(( but he give me this link github.com/VKCOM/vk-android-sdk, maybe it will help you.Gittern
They answered me, so I told them to put the answer on SO, so that I could thank them. Anyway, thank you for your help !Phylactery
F
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))
}
Frizz answered 5/8, 2016 at 20:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.