0

I have a Phone Gap Android app which uses Facebook JS SDK to create Facebook share dialog. I tested on 3 devices. It works perfectly fine on one device, but the other two produce no results. When I press the share button, it does nothing.

I was able to determine the FB.getLoginStatus returns "unknown" on the devices that fail to work. However, I am logged into FB via login dialog inside the app. The working device correctly returns "connected".

Also, Like and Comment features work fine on all devices.

Devices work fine

Nexus 7 - 5.1.1 (fb user is admin of the FB app)

Devices share dialog:

Galaxy Trend - 4.0.4 (fb user is admin or developer of the FB app)

Lenovo Tablet - 4.1.2 (fb user has no association with the FB app)

The FB app is not in sandbox, it is live.

Here is my share function.

function sharepost(link,picture,name,description,post_type,page_name){

            var description_unes = unescape(description);
            FB.getLoginStatus(function(response) {

                if (response.status == 'connected') {

                    var obj = {
                        method: 'feed',
                        link: link, 
                        picture: "http://example.com/fb.php?u=hsttps://fbexternal-a.akamaihd.net/safe_image.php?d=AQDQXWajSt1TJxUz&url="+picture, //full_picture
                        name: name,  
                        description: description_unes
                    };
                    FB.ui(
                        obj,
                        function(response) {
                            if (response && !response.error_code) {
                              alert('Posting completed.');
                            } else {
                              alert('Error while posting.');
                            }
                        }
                    );
                }
            });
        }

Anybody ran into similar issue where the behavior differs based on a mobile device (or I guess the android SDK version?). thanks much

UPDATE: I read here FB.getLoginStatus() return "unknown" in Firefox when user is logged that in a browser it is related to 3rd party cookies, but how can this be when this is an Android App. When I get authenticated into the app, the status is "connected", but then when I share, the status becomes "unknown".

Community
  • 1
  • 1
Kenneth Browning
  • 1,360
  • 1
  • 13
  • 22

1 Answers1

0

Figured out my own question:). It turns out that I need to add the "true" parameter to FB.getLoginStatus() to force a roundtrip to the FB server and retrieve the correct status. To be honest, I don't know why this would be the case since the status should have been cached (if anybody knows, please share). Perhaps a better solution would be to set status:true in the FB.init call and then subscribe to auth.statusChange (have not tested this yet though.

Kenneth Browning
  • 1,360
  • 1
  • 13
  • 22