簡體   English   中英

Facebook SDK 3.1.1,iOS 6,FBNativeDialogs

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM