Facebook SDK 3.0 with old Facebook app version red

2019-04-08 14:29发布

问题:

I have in my app a FB AuthButton that is doing the connection to FB process
I have a device that is running an old version of the FB app (version 1.8.3 - 1.8.4).

when I click on the login button, the process doesn't start the native app, but calls the browser to finish the process.
In the logs, I see those logs:

06-16 12:26:00.709: E/ActivityThread(21597): Failed to find provider info for com.facebook.katana.provider.AttributionIdProvider
06-16 12:26:03.321: E/Tab(21678): onReceivedError -10 fbconnect://success#access_token=MY_TOKEN&expires_in=5170432 The protocol is not supported.

and on the screen, the browser shows this screenshot:

any thoughts on how to fix this or ridirect back to my app?

回答1:

We've found that Facebook version 1.9.8+ works, which is version code version code 40477+.

As we are using the deprecated Facebook.java class, we modified validateAppSignatureForPackage(). It seems to work for all versions of the facebook app now.

private boolean validateAppSignatureForPackage(Context context, String packageName) 
{
    PackageInfo packageInfo;
    try 
    {
        packageInfo = context.getPackageManager().getPackageInfo(packageName, 
                      PackageManager.GET_SIGNATURES);
        if(packageInfo.versionCode<40477)
        {
            Log.i("validateAppSignatureForPackage", 
              "Your facebook app version is prior to 1.9.8. Update your facebook app"); 
            return false;
        }
    } 
    catch (NameNotFoundException e) 
    {
        Log.i("validateAppSignatureForPackage", e.getMessage());
        return false;
    }
    catch(Exception e)
    {
        Log.i("validateAppSignatureForPackage", e.getMessage());
        return false;
    }

    for (Signature signature : packageInfo.signatures) {
        if (signature.toCharsString().equals(FB_APP_SIGNATURE)) {
            return true;
        }
    }
    return false;
}

If you want to test this yourself, you can find previous versions of the facebook app here: http://www.androiddrawer.com/2274/download-facebook-for-android-1-9-7-app-apk/#.Uctn6Zwaux4