Facebook Connect Safari无法打开页面

时间:2012-03-10 14:38:47

标签: objective-c ios xcode facebook

我正在使用faceobok connect和下面的官方Facebook教程: https://developers.facebook.com/docs/mobile/ios/build/ 现在,当我模拟它进入Facebook然后它是关于应用程序的东西,你按完了。当我按完了它时,sais safari无法打开页面,因为它是一个无效的地址。这是我的财产清单:

这是我的代码:

   - (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [facebook handleOpenURL:url]; 
}

// For iOS 4.2+ support
 - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
 sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [facebook handleOpenURL:url]; 
}

  - (void)fbDidLogin {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
[defaults synchronize];

  }

  -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:  (NSInteger)buttonIndex       {

if (buttonIndex == 0) {
    // facebook
    facebook = [[Facebook alloc] initWithAppId:@"387500177929927" andDelegate:self];
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    if ([defaults objectForKey:@"FBAccessTokenKey"] 
        && [defaults objectForKey:@"FBExpirationDateKey"]) {
        facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
        facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
    }

    if (![facebook isSessionValid]) {
        [facebook authorize:nil];
    }
}
 }

物业清单:

  <?xml version="1.0" encoding="UTF-8"?>
   <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"            
   "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
   <array>
<dict>
    <key>CFBundleURLSchemes</key>
    <array>
        <string>387500177929927</string>
    </array>
</dict>
  </array>
  </plist>

1 个答案:

答案 0 :(得分:4)

您的CFBundleURLSchemes键看起来不对,该应用应该是fb387500177929927,而不是387500177929927

来自the docs

  

使用单个项目URL Schemes创建一个名为URL类型的新行       包含单个值fbYOUR_APP_ID(文字字符fb       然后是您的应用ID)。