简体   繁体   中英

Facebook SDK 3.2 for iOS 6: Can't login -> openURL not called / AppId & URL is correct

Hiho

I have a big problem with the new Facebook SDK 3.2 for iOS 6 (I use the iPhone simulator for testing). I've implement the Facebook Login exactly like described in the how-to. The only difference is that I didn't implement it within the app delegate. I implemented the Facebook-Stuff in one seperate mm-file (but I've tested the code within the app delegate too -> same problem!).

That is what happen: If I try to login, a UIView (maybe it's a UIWebView) pops up in the middle of the screen and I can enter my Account-Credentials. As next comes the Permission-Confirming-Screen. I click the OK-Button and then comes the Error: "The operation couldn't be completed. (com.facebook.sdk error 2.)" UserInfo=0x14bbd590 {com.facebook.sdk:ErrorLoginFailedReason=com.facebook.sdk:ErrorLoginNotCancelled}

I've already experiences with the old facebook-sdk v2. There where no problems to integrate! But with the new one and iOS 6 I can't get it to run :-(

I think one essential problem could be that the method openURL of the UIApplicationDelegate is not called! I've insert the AppID into the info.plist and added the URL Type too. It looks like this snippet:

<key>CFBundleURLTypes</key>
<array>
<dict>
  <key>CFBundleURLSchemes</key>
    <array>
      <string>fb111111111111111</string>
    </array>
</dict>
</array>
<key>FacebookAppID</key>
<string>111111111111111</string>

I've also analyzed the url with wireshark:

https://www.facebook.com/login.php?app_id=111111111111111&sdk=ios&skip_api_login=1&cancel=fb111111111111111%3A%2F%2Fauthorize%2F%3Ferror_reason%3Duser_denied%26error%3Daccess_denied%26error_description%3DThe%2Buser%2Bdenied%2Byour%2Brequest.&fbconnect=1&next=https%3A%2F%2Fm.facebook.com%2Fdialog%2Fpermissions.request%3F_path%3Dpermissions.request%26app_id%3D111111111111111%26client_id%3D111111111111111%26redirect_uri%3Dfb111111111111111%253A%252F%252Fauthorize%26sdk%3Dios%26display%3Dtouch%26type%3Duser_agent%26fbconnect%3D1%26sso%3Diphone-safari%26from_login%3D1&rcount=1&_rdr

same url if decoded: https://www.facebook.com/login.php?app_id=111111111111111&sdk=ios&skip_api_login=1&cancel=fb111111111111111://authorize/?error_reason=user_denied&error=access_denied&error_description=The+user+denied+your+request.&fbconnect=1&next=https://m.facebook.com/dialog/permissions.request?_path=permissions.request&app_id=111111111111111&client_id=111111111111111&redirect_uri=fb111111111111111%3A%2F%2Fauthorize&sdk=ios&display=touch&type=user_agent&fbconnect=1&sso=iphone-safari&from_login=1&rcount=1&_rdr

I also double-checked that the app-ids are equal on all relevant spots (info.plist/url/dev-site: Bundle ID)!

Don't know if its an important info but we don't use any xib-files in our app, because its an 3D-Game which uses our own 3d-engine. And the provided screen-orientation is landscape only. I use Xcode version 4.5.2 (4G2008a).

Any Ideas?

3 Additional Questions (maybe it helps me to get more infos):

  1. How I can obtain more infos about whats going wrong? "com.facebook.sdk error 2" is not very helpful :-/

  2. Is there an easy way to test the automatic redirect call of the openURL methods from the UIApplicationDelegate?

  3. Is there a way to force the sdk to login with the safari-browser instead of the view?

thx in advance

martin

I found a solution: You have to call the method 'canOpenURL' within the method 'application: didFinishLaunchingWithOptions' like this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  ...
  [[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:@"fb111111111111111"]];
  ...
  return YES; //or NO;  doesn't matter
}

The effect is now that the sdk trys to login with the safari browser instead with the stupid WebView :-)

_

HINT:

You can read the URL Scheme direct from the info.plist file:

NSString urlScheme = [[[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleURLTypes"] objectAtIndex:0] objectForKey:@"CFBundleURLSchemes" objectAtIndex:0];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM