我正在尝试将新的oAuth2 facebook SDK应用到我的应用程序中,但在我的生活中不能理解我应该在登录/验证后回到我的应用程序。
我的目标是在用户墙上发布消息。
我目前正在使用以下方式启动登录程序:
-(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];
}
正在打开一个Safari浏览器。如果我已经登录并且已经授权应用程序,则会告诉我这样的消息并且我有一个OKay按钮可以按下。
当我按下OKay按钮时,我收到提示,说safari无法打开页面。我确认了警报,我还在看一个空白的野生动物园窗口。
如果我退出Facebook,我会看到我填写的登录屏幕,然后会显示与上面相同的内容。
据我所知,我还没有在任何地方实现发布命令,因为我不知道应该在何时/何时实现。
我确实有这种委托方法,但似乎永远不会被称为
- (void)fbDidLogin {
NSLog(@"fbDidLogin");
}
这是我等待放置的代码:
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];
我的应用程序主AppDelegate中也有以下方法:
-(BOOL) application:(UIApplication *)application handleOpenURL:(NSURL *)url{
[facebook handleOpenURL:url];
return YES;
}
非常感谢任何帮助/建议。
由于
标记
答案 0 :(得分:25)
我有同样的问题。只是为了澄清其他一些答案,以下是我在Xcode 4.2中解决iPhone应用程序问题的方法:
.plist file
"URL types"
"Item 0"
"URL Schemes"
"Item 0"
"fb21593853845xxxx"
答案 1 :(得分:0)
Arg,你最好打开.plist作为代码源,你应该看到:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>fb38*******</string>
</array>
</dict>
</array>
答案 2 :(得分:-1)
您必须将AppID写入.plist