当我尝试在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];
}
答案 0 :(得分:0)
您需要在设备/模拟器上设置Facebook帐户(在“设置” - >“Facebook”下)。