开发者

UIButton to open Facebook app

开发者 https://www.devze.com 2023-02-06 22:42 出处:网络
im trying to make a button that will exit my app and open up the facebook app (if available) 开发者_JAVA技巧to my apps profile. And I cant figure out how I would do this.Get your button to call the fo

im trying to make a button that will exit my app and open up the facebook app (if available) 开发者_JAVA技巧to my apps profile. And I cant figure out how I would do this.


Get your button to call the following method when clicked:

- (void)buttonClicked:(id)sender {

    NSURL *url = [NSURL URLWithString:@"fb://profile/<your_profile_id>"];

    if ([[UIApplication sharedApplication] canOpenURL:url]) {
        [[UIApplication sharedApplication] openURL:url];
    }

}

If the Facebook app is installed on your device, then it should open to your profile.


Facebook app on the iPhone conforms to the fb:// URL pattern, fb://profile/{profile id number} will open the Facebook app to the specified profile id number

You could make your button open the URL specific to your apps profile.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号