如何发送用户到Facebook页面上的按钮点击 [英] How to send user to Facebook page on button click

查看:131
本文介绍了如何发送用户到Facebook页面上的按钮点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iOS开发新手,请耐心等待。



我正在创建一个简单的应用程序。有一个Facebook按钮,我希望该按钮将用户发送到我的Facebook页面,无论是在浏览器中还是打开了Facebook应用程序。



我知道可能有很多解释,但如果有人能指出我的方向是非常好的,谢谢。

解决方案

截至Facebook的4.0更新,您可以跳转到具有此URI架构的页面:

  fb:// page / {fbid} 

只要确保你检查以确保您正在使用的设备可以响应:

  [[UIApplication sharedApplication] canOpenURL:[NSURL urlWithString:@ FB://页/ {FBID}]]; 

您的方法可能会看起来像这样:



{pre> - (IBAction)openFBPage:(id)sender {
if([[UIApplication sharedApplication] canOpenURL:[NSURL urlWithString:@fb:// page / fbid}]]){
[[UIApplication sharedApplication] openURL:[NSURL urlWithString:@fb:// page / {fbid}]];
} else {
NSLog(@Facebook未安装);
//或做一个明智的事情,openURL在safari的页面的HTTP版本
}

...并且您将链接上述方法与您在Interface Builder中的按钮。


I'm new to iOS development so please bear with me..

I'm in the process of creating a simple app. There is a facebook button and I'd like that button to send the user to my facebook page, either in the browser or if they have the facebook app open that up.

I know there's probably a lot to explain, but if someone could point me in the right direction that would be great, thanks.

解决方案

As of the 4.0 update for Facebook, you can jump to pages with this URI schema:

fb://page/{fbid}

Just make sure you check to make sure that the device you're working with can respond to it:

[[UIApplication sharedApplication] canOpenURL:[NSURL urlWithString:@"fb://page/{fbid}"]];

Your method might end up looking something like this:

- (IBAction)openFBPage:(id)sender {
    if ([[UIApplication sharedApplication] canOpenURL:[NSURL urlWithString:@"fb://page/{fbid}"]]) {
        [[UIApplication sharedApplication] openURL:[NSURL urlWithString:@"fb://page/{fbid}"]];
    } else {
        NSLog(@"Facebook isn't installed.");
        // or do the sensible thing and openURL the HTTP version of the page in safari
}

... and you'd link the above method with your button in Interface Builder.

这篇关于如何发送用户到Facebook页面上的按钮点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆