简体   繁体   中英

Facebook page link open in facebook app instead of safari browser

I am developing an iPhone app in that i need to open facebook page link in safari browser. I did it by following code on button clicked method.

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

This code will open safari browser in iPhone and display facebook page. But problem is when in device facebook application is installed then this code open facebook app instead of safari browser. Problem created when in device have facebook app installed. I want same behaviour whether there is facebook application is installed or not.

Suggest some idea. Code is fully welcome. thanks in adv.

make it this way

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString: @"fb://profile/<page id>"]]){
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"fb://profile/<page id>"]];
}else{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://www.facebook.com/<page name>"]];
}

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