0

I have a problem with FBSDKLoginManagerRequestTokenHandler as it should be invoked, but it is not.

let login = FBSDKLoginManager()

login.logInWithReadPermissions(["email"]) { (result, error) in
  // should be retuned here after dismissing Safari, as I understood, but app never call this block.
}

It works perfect at the first step, so app open safari and I able to login on Facebook.

It says "App is already authorized" and I tapped on Ok button on Safari and then I see an alert which says "Open this page in my app", I tap open and nothing happen. I mean there is no call back in return.

Details:

  • iPhone 6 plus with iOS 9.2.1

  • pod 'Facebook-iOS-SDK', '~>4.1'

Alos as I noticed I have this error in my log:

-canOpenURL: failed for URL: "fbauth://authorize/?client_id=1150389881653102&default_audience=friends&display=touch&e2e=%7B%22init%22%3A1459873693399%7D&legacy_override=v2.3&redirect_uri=fbconnect%3A%2F%2Fsuccess&response_type=token%2Csigned_request&return_scopes=true&scope=email&sdk=ios&sdk_version=4.1.0&state=%7B%22com.facebook.sdk_client_state%22%3Atrue%2C%223_method%22%3A0%2C%220_auth_logger_id%22%3A%228FB19521-A8ED-49DA-A7DC-E5382029252C%22%7D" - error: "This app is not allowed to query for scheme fbauth"

Adding data to plist does not help as suggested here. I've added this:

<key>LSApplicationQueriesSchemes</key>
<array>
        <string>fbapi</string>
        <string>fb-messenger-api</string>
        <string>fbauth2</string>
        <string>fbshareextension</string>
</array>

I have this in app delegate:

public func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool
{
  return self.applicationManager.application?(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation) ?? false
}

but see it's deprecated in iOS 9

Community
  • 1
  • 1
Matrosov Oleksandr
  • 25,505
  • 44
  • 151
  • 277
  • as you have not mentioned did you setup `application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool` ? also the url schemes ? – HardikDG Apr 05 '16 at 16:23
  • @Pyro hey, I've added new comments to a question, thanks – Matrosov Oleksandr Apr 05 '16 at 16:33

1 Answers1

0

Better solution will be you update your Facebook SDK to latest version, but if there is some specific requirement of the version you specified you can check the following

The link you have provided in the question suggest

If you're recompiling with iOS SDK 9.0, add the following to your application's plist if you're using a version of the SDK v4.5 or older:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbapi</string>
    <string>fbapi20130214</string>
    <string>fbapi20130410</string>
    <string>fbapi20130702</string>
    <string>fbapi20131010</string>
    <string>fbapi20131219</string>    
    <string>fbapi20140410</string>
    <string>fbapi20140116</string>
    <string>fbapi20150313</string>
    <string>fbapi20150629</string>
    <string>fbauth</string>
    <string>fbauth2</string>
    <string>fb-messenger-api20140430</string>
</array>

as you have mentioned you are using version 4.1, if you are using version 4.10 your plist should work as you have mentioned

For the method you can implement this, it is working for me in swift 2.2

application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
}

For the more info regarding integration, you can check :

FB SDK doc
FB Login sample: Medium


Update: So there may be some problem regarding the openURL as the warning is okay as per FB doc

This is an Xcode warning indicating the the canOpenURL: call returned false. As long as you have configured the LSApplicationQueriesSchemes entry in your plist as described above, you can ignore this warning

Reference: https://developers.facebook.com/docs/ios/ios9 , check at the bottom

HardikDG
  • 5,892
  • 2
  • 26
  • 55
  • thanks for answer! I still have an issue as I mention regarding canOpenURL and there is no call back in return after open app from safari – Matrosov Oleksandr Apr 06 '16 at 11:14
  • @MatrosovAlexander please check your openUrl method with some other fb example as the warning should be ok as per fb doc mentioned in my updated answer – HardikDG Apr 06 '16 at 12:45
  • ok thanks for update, I am also trying use pod 'FBSDKLoginKit', '~> 4.10' instead. is this ok? It drops an error: `#import ` - not found – Matrosov Oleksandr Apr 06 '16 at 13:18