Facebook Android sdk bug - postRequest 'extinfo' json array generated with backslashes

187 views Asked by At

I need to connect my Android application with Facebook Analytics, using custom events.

I followed official documentation on https://developers.facebook.com/docs/analytics/

Added facebook SDK into the project:

implementation 'com.facebook.android:facebook-android-sdk:5.15.3'

Generated all the necessary hashes, put everything necessary in the Manifest, all good.

App was built and launched, however, events were never showing up in the Analytics Console.

After hours and hours of debugging, I've found the problem.

Inside Facebook SDK library code, when postRequest to server is created, it has (among others) parameter called "extInfo". This parameter should contain json array with strings, in certain order.

Now, that's how Facebook SDK postRequest looks, when sent from the application:

enter image description here

As you can see, extinfo json array is all contaminated with backslashes. When I replicated this request manually in Postman, server returned error:

"message": "(#100) Field extinfo must be a valid json object with string keys"

So, in Postman, I modified extinfo parameter - cleaned it out of backslashes:

enter image description here

Result from server in this case is: "success": true. Events started appearing inside Analytics Dashboard.

Wonderful. But.

How to send events with the help of Facebook SDK, considering this bug? Is there sdk version where this bug doesn't appear? Is there a way to tune sdk so that it doesn't send extinfo at least? Any other possible solution, except for sending requests without help of Facebook SDK (that's a whole load to write, besides, if they change request structure, code has to be re-written)?

I haven't found metions of this bug anywhere in the Internet. If there is, please share a link. Thank you.

Edit: tried with implementation 'com.facebook.android:facebook-core:7.1.0' too. No luck.

1

There are 1 answers

0
Valeriya On

I've found the solution. In my case, problem was inside the project and had nothing to do with Facebook SDK. Previous developer created validation for hosts that application can use:

 HttpsURLConnection.setDefaultSSLSocketFactory(socketFactory)

        val verify = fun(ip: String, _: SSLSession): Boolean {
            println(ip)
            return ip.contains("crashlytics", true) ||
                    ip.contains("firebase", true) ||
                    ip.contains("maps.googleapis.com", true) ||
                    ip.contains("facebook.com", true)
        }

        HttpsURLConnection.setDefaultHostnameVerifier(verify)

Once I added facebook.com in the list, error was gone. However, I still don't understand why in the log "extinfo" parameter was generated with backslashes.