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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7666684/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 22:04:26  来源:igfitidea点击:

Facebook iOS SDK not returning to my app

iosxcodefacebook

提问by crooksy88

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.

这是打开一个 safari 浏览器。如果我已经登录并获得了应用程序授权,则会有一条消息告诉我,我有一个 OKay 按钮可以按下。

When I press the OKay button I get an alert saying safari cannot open the page. I confirm the alert and am left looking at a blank safari window.

当我按下 OKay 按钮时,我收到一条警告,说 safari 无法打开页面。我确认了警报,然后看着一个空白的 safari 窗口。

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

标记

回答by Greg M. Krsak

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"

回答by Thomas Decaux

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>

回答by Okan

You must write your AppID to your .plist

您必须将您的 AppID 写入您的 .plist