简体   繁体   English

Facebook iOS SDK没有返回我的应用程序

[英]Facebook iOS SDK not returning to my app

I'm trying to implement the new oAuth2 facebook SDK into my app but can't for the life of me understand how I'm supposed to get back to my app once logged in/authenticated. 我正在尝试将新的oAuth2 facebook SDK应用到我的应用程序中,但在我的生活中无法理解我应该在登录/验证后回到我的应用程序。

My goal is to post a message on the users wall. 我的目标是在用户墙上发布消息。

I am currently starting the login procedure with this: 我目前正在使用以下命令启动登录程序:

-(void)tryFBlogin {

NSString *appId = @"113142482******";

NSArray *permissions =  [[NSArray arrayWithObjects:@"publish_stream",nil] retain];

TheAppDelegate *theAppDelegate = (TheAppDelegate *)[[UIApplication sharedApplication]delegate];

//Asking for permission
theAppDelegate = (TheAppDelegate *)[[UIApplication sharedApplication] delegate];
theAppDelegate.facebook = [[Facebook alloc] initWithAppId:appId andDelegate:self];
Facebook *fb = [theAppDelegate facebook];
[fb  authorize:permissions];

}

which is opening a safari browser. 这是打开野生动物园浏览器。 If I'm already logged in and have the app authorized a message will tell me so and I have an OKay button to press. 如果我已经登录并且已经授权应用程序,则会告诉我这样的消息并且我有一个OKay按钮可以按下。

When I press the OKay button I get an alert saying safari cannot open the page. 当我按下OKay按钮时,我收到警告,说safari无法打开页面。 I confirm the alert and am left looking at a blank safari window. 我确认了警报,我还在看一个空白的野生动物园窗口。

If I'm logged out of facebook I am presented with the login screen which I fill in and am then presented with the same as above. 如果我退出Facebook,我会看到我填写的登录屏幕,然后显示与上面相同的内容。

I understand that I haven't implemented the publish command anywhere yet as I don't know where/when this should be implemented. 我知道我还没有在任何地方实现发布命令,因为我不知道应该在何时/何时实现。

I do have this delegate method in place but this seems to never get called 我确实有这个委托方法,但似乎永远不会被调用

- (void)fbDidLogin {

    NSLog(@"fbDidLogin");
}

This is the code I have waiting to place somewhere: 这是我等待放置的代码:

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
kAppId, @"113142482******",
facebookUrl, @"link",
@"http://www.domain.com", @"picture",
@"My Message", @"name",
@"Caption text!", @"caption",
@"Message text.",  @"message",
nil];

[facebook dialog:@"feed" andParams:params andDelegate:self];

I also have the following methods in my apps main AppDelegate: 我的应用程序主AppDelegate中也有以下方法:

-(BOOL) application:(UIApplication *)application handleOpenURL:(NSURL *)url{
    [facebook handleOpenURL:url]; 
return YES; 
}

Any help/suggestions would be very much appreciated. 任何帮助/建议将非常感谢。

Thanks 谢谢

Mark 标记

I had this same problem. 我有同样的问题。 Just to clarify some of the other answers, here's how I fixed the issue for my iPhone app in Xcode 4.2: 只是为了澄清其他一些答案,以下是我如何在Xcode 4.2中解决我的iPhone应用程序的问题:

.plist file
    "URL types"
    "Item 0"
        "URL Schemes"
        "Item 0"
            "fb21593853845xxxx"

Arg, you better open .plist as code source, you should see : Arg,你最好打开.plist作为代码源,你应该看到:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>fb38*******</string>
        </array>
    </dict>
</array>

您必须将AppID写入.plist

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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