简体   繁体   中英

Open a shared link in facebook to open in native app if installled in iphone

I am struggling with one thing. Below is the scenario:

I have a website which has a feature to share a link with facebook. What I want is if someone has the facebook app installed in the iPhone and clicks on the link, it should open it in the app to which that link belongs, if that app is installed.

Could you help me? How can I achieve this ?

You need the URL scheme, which can be found here

Facebook iOS URL Scheme

You will need to open the URL like so

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.some URL.com"]];

You can check and open some specifics applications using url which they are shared their url scheme here .

For example with facebook, you can check if the user has the app installed :

[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"fb://profile"]];

And call this method to open the application :

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"fb://profile"]];

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM