[英]Facebook sdk 3.1.1, ios 6, FBNativeDialogs
当我尝试在ios 6上显示共享对话框时,我的应用程序未显示FBNativeDialogs!
我正在使用DEFacebookComposeViewController库,在ios 4.3、5.0和5.1上还可以,该对话框在应用程序获取facebooktoken后出现。 但是在iOS 6上,如果该应用程序具有Facebook令牌(我是说该应用程序已经安装了令牌,例如用户使用Facebook登录),则不会出现该对话框。 仅在没有令牌然后才起作用的情况下显示。 并与iOS 6 DEFacebookComposeViewController它不起作用。 FBNativeDialogs返回,错误代码为7。所以我的问题是如何在iOS 6上调用DEFacebookComposeViewController或在已有Facebook令牌的情况下如何使用FBNativeDialogs。
BOOL displayedNativeDialog = [FBNativeDialogs
presentShareDialogModallyFrom:self
initialText:@""
image:nil
url:[NSURL URLWithString:@"www.google.com"]
handler:^(FBNativeDialogResult result, NSError *error) {
// Only show the error if it is not due to the dialog
// not being supporte, i.e. code = 7, otherwise ignore
// because our fallback will show the share view controller.
if (error && [error code] == 7) {
return;
}
NSString *alertText = @"";
if (error) {
alertText = [NSString stringWithFormat:
@"error: domain = %@, code = %d",
error.domain, error.code];
} else if (result == FBNativeDialogResultSucceeded) {
alertText = @"Posted successfully.";
}
if (![alertText isEqualToString:@""]) {
// Show the result in an alert
[[[UIAlertView alloc] initWithTitle:@"Result"
message:alertText
delegate:self
cancelButtonTitle:@"OK!"
otherButtonTitles:nil]
show];
}
}];
// Fallback, show the view controller that will post using me/feed
if (!displayedNativeDialog)
{
UIDevice *device = [UIDevice currentDevice];
CGFloat systemVersion = [[device systemVersion] floatValue];
if (systemVersion > 5.5)
{
return;
}
DEFacebookComposeViewController *facebookViewComposer = [[DEFacebookComposeViewController alloc] init];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[facebookViewComposer setInitialText:@""];
[facebookViewComposer addURL:@"www.google.com"]];
[facebookViewComposer setCompletionHandler:^(DEFacebookComposeViewControllerResult result) {
switch (result) {
case DEFacebookComposeViewControllerResultCancelled:
NSLog(@"Facebook Result: Cancelled");
break;
case DEFacebookComposeViewControllerResultDone:
NSLog(@"Facebook Result: Sent");
break;
}
[facebookViewComposer dismissModalViewControllerAnimated:YES];
}];
[self presentModalViewController:facebookViewComposer animated:YES];
[facebookViewComposer release];
}
您需要在设备/模拟器上设置Facebook帐户(在“设置”->“ Facebook”下)。
更多详细信息: http : //facebook.stackoverflow.com/questions/12592898/facebook-sdk-3-1-presentsharedialogmodally-fails/12681352#12681352
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.