Failing to open active session after updating Facebook SDK to 3.5

后端 未结 6 984
别那么骄傲
别那么骄傲 2021-01-04 19:25

After updating the Facebook sdk to 3.5, when trying to perform openActiveSessionWithReadPermissions the operation fails. Here is the snippet for opening the session and hand

相关标签:
6条回答
  • 2021-01-04 19:54

    I am getting the same error but solved by below info.plist hierarchy:

    `
     <key>URL Types</key>
     <array>  
       <dict>
         <key>URL Schemes</key>    
         <array>      
          <string>fb***</string>    
         </array>    
       </dict> 
     </array>
    `
    
    0 讨论(0)
  • 2021-01-04 20:06

    I Had the same problem (Facebook SDK 3.5.1)

    My URL scheme for Facebook was on Item 1 in the Info.plist URL schemes. Problem fixed by moving it to Item 0.

    0 讨论(0)
  • 2021-01-04 20:07

    I had the same problem. The code above fixed this issue. U have to edit your .plist file with text editor. But in Xcode u will not see any changes. Instead of URL Types - CFBundleURLTypes and instead of URL Schemes should be CFBundleURLSchemes.

    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fb48524**********</string>
            </array>
        </dict>
    </array>
    
    0 讨论(0)
  • 2021-01-04 20:09

    Lola's answer worked for me. If you have multiple URL Types - e.g. Facebook's and one for your app - it's helpful to give the one you handle yourself a bundle identifier equal to your app's bundle identifier, then iterate through your URL Types to find it.

    At the beginning of my app delegate I just run:

    NSArray *urlSchemes = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleURLTypes"];
    for (NSDictionary *scheme in urlSchemes) {
        if ([[scheme objectForKey:@"CFBundleURLName"] isEqualToString:[[NSBundle mainBundle] bundleIdentifier]]) {
            self.urlScheme = [[scheme objectForKey:@"CFBundleURLSchemes"] objectAtIndex:0];
            break;
        }
    }
    

    and then (since we have multiple environments with different FB App Ids)

    -(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
        if ([url.scheme hasPrefix:@"fb"]) {
            //Facebook callback
            return [FBSession.activeSession handleOpenURL:url];
        // else handle your own URL here
    
    0 讨论(0)
  • 2021-01-04 20:10

    It seems that I had a URL Scheme that didn't match my FacebookAppId. For whatever reason this didn't seem to be a problem before but is relevant now. Make sure your Facebook URL Scheme is your FacebookAppID prefixed with fb (in your .plist files). For example:

    FacebookAppId: 123456789012345

    URL types -> Item 0 -> URL Schemes -> Item 0: fb123456789012345

    0 讨论(0)
  • 2021-01-04 20:11
    adding URL Scheme in plist file is solved my problem
    
    <?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>fb8947128947(fb<App ID>)</string>
            </array>
        </dict>
    </array>
    </plist>
    
    0 讨论(0)
提交回复
热议问题